home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / kr_amap.c < prev    next >
C/C++ Source or Header  |  1994-04-25  |  159KB  |  6,171 lines

  1. /*****************************************************************************
  2.   FILE           : kr_amap.c
  3.   SHORTNAME      : 
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : SNNS Kernel Functions for ARTMAP networks
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Kai-Uwe Herrmann
  10.   DATE           : 17.05.92
  11.  
  12.   CHANGED BY     : Sven Doering
  13.   IDENTIFICATION : @(#)kr_amap.c    1.7 3/15/94
  14.   SCCS VERSION   : 1.7
  15.   LAST CHANGE    : 3/15/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20. #include <stdlib.h>
  21.  
  22.  
  23.  
  24. #ifndef NULL /* if NULL pointer is not defined include stdio.h */
  25. #include <stdio.h>
  26. #endif
  27.  
  28.  
  29. #include "kr_const.h"
  30. #include "kr_mac.h"
  31. #include "kr_def.h"
  32. #include "kr_typ.h"
  33. #include "kr_funcs.h"
  34. #include "kernel.h"
  35. #include "glob_typ.h"
  36. #include "kr_art.h"     /*  Function prototypes for ART networks */
  37. #include "krart_df.h"   /*  Definitions for ART networks */
  38. #include "kr_amap.ph"
  39.  
  40.  
  41.  
  42. /*#################################################
  43.  
  44. GROUP: ARTMAP kernel functions
  45.        by Kai-Uwe Herrmann
  46.  
  47. #################################################*/
  48.  
  49. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  50. krui_err kram_init_i_act (double rhoa, double rhob, double rho)
  51. {
  52.    int                    ret_code = KRERR_NO_ERROR;
  53.  
  54.    register struct Unit   *unit_ptr;
  55.  
  56.  
  57.    FOR_ALL_UNITS (unit_ptr) {
  58.  
  59.       switch (unit_ptr->lln) {
  60.  
  61.       case ARTMAP_SPECa_LAY:
  62.          switch (unit_ptr->lun) {
  63.          case ARTMAP_G1a_UNIT :
  64.             unit_ptr->i_act = 0.0;
  65.             break;
  66.          case ARTMAP_RIa_UNIT :
  67.             unit_ptr->i_act = 1.0;
  68.             break;
  69.          case ARTMAP_RGa_UNIT :
  70.             unit_ptr->i_act = 1.0;
  71.             break;
  72.          case ARTMAP_RHOa_UNIT :
  73.             unit_ptr->i_act = (FlintType) rhoa;
  74.             break;
  75.          default :
  76.             unit_ptr->i_act = 0.0;
  77.             break;
  78.          } /*switch*/
  79.          break;
  80.  
  81.       case ARTMAP_SPECb_LAY:
  82.          switch (unit_ptr->lun) {
  83.          case ARTMAP_G1b_UNIT :
  84.             unit_ptr->i_act = 0.0;
  85.             break;
  86.          case ARTMAP_RIb_UNIT :
  87.             unit_ptr->i_act = 1.0;
  88.             break;
  89.          case ARTMAP_RGb_UNIT :
  90.             unit_ptr->i_act = 1.0;
  91.             break;
  92.          case ARTMAP_RHOb_UNIT :
  93.             unit_ptr->i_act = (FlintType) rhob;
  94.             break;
  95.          default :
  96.             unit_ptr->i_act = 0.0;
  97.             break;
  98.          } /*switch*/
  99.          break;
  100.  
  101.       case ARTMAP_SPEC_LAY:
  102.          switch (unit_ptr->lun) {
  103.          case ARTMAP_G_UNIT:
  104.             unit_ptr->i_act = 1.0;
  105.             break;
  106.          case ARTMAP_RHO_UNIT:
  107.             unit_ptr->i_act = (FlintType) rho;
  108.             break;
  109.          default:
  110.             unit_ptr->i_act = 0.0;
  111.             break;
  112.          } /*switch*/
  113.          break;
  114.  
  115.       default :
  116.          unit_ptr->i_act = 0.0;
  117.          break;
  118.       } /*switch*/
  119.  
  120.    } /*FOR_ALL_UNITS*/
  121.  
  122.  
  123.    return (ret_code);
  124.  
  125. } /* kram_init_i_act () */
  126. /*___________________________________________________________________________*/
  127.  
  128.  
  129.  
  130. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  131. krui_err  kram_sort (void)
  132. {
  133.    krui_err             ret_code    = KRERR_NO_ERROR;
  134.  
  135.    TopoPtrArray         topo_ptr = topo_ptr_array;
  136.  
  137.    int                  no_of_cmpa_units  = 0;
  138.    int                  no_of_dela_units  = 0;
  139.    int                  no_of_rsta_units  = 0;
  140.    int                  no_of_speca_units = 0;
  141.    int                  no_of_cmpb_units  = 0;
  142.    int                  no_of_delb_units  = 0;
  143.    int                  no_of_rstb_units  = 0;
  144.    int                  no_of_specb_units = 0;
  145.    int                  no_of_map_units   = 0;
  146.    int                  no_of_spec_units  = 0;
  147.  
  148.  
  149.  
  150.    /* initialize ARTMAP sorting
  151.    */
  152.    krart_init_sorting ();
  153.  
  154.    /* get no of input units
  155.    */
  156.    NoOfInputUnits = krart_get_NoOfInputUnits ();
  157.  
  158.    if (NoOfInputUnits == 0) {
  159.       ret_code = KRERR_NO_INPUT_UNITS;
  160.       return (ret_code);
  161.    } /*if*/
  162.  
  163.    /* insert the initial NULL-ptr into the topo ptr array
  164.    */
  165.    *topo_ptr++ = NULL;
  166.  
  167.    /**********  determine unit types for ARTa and insert them into topo ptr array
  168.    **********/
  169.  
  170.    /* determine input units of ARTa
  171.    */
  172.    ret_code = kram_get_InpUnits_a (&topo_ptr, &ArtMap_NoOfInpUnits_a);
  173.  
  174.    if (ret_code != KRERR_NO_ERROR) {
  175.       return (ret_code);
  176.    } /*if*/
  177.  
  178.    if (ArtMap_NoOfInpUnits_a == 0) {
  179.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTa input");
  180.    } /*if*/
  181.  
  182.    *topo_ptr++ = NULL;
  183.  
  184.  
  185.    /* determine comparison units of ARTa
  186.    */
  187.    ret_code = kram_get_CmpUnits_a (&topo_ptr, &no_of_cmpa_units);
  188.  
  189.    if (ret_code != KRERR_NO_ERROR) {
  190.       return (ret_code);
  191.    } /*if*/
  192.  
  193.    if (no_of_cmpa_units != ArtMap_NoOfInpUnits_a) {
  194.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTa comparison");
  195.    } /*if*/
  196.  
  197.    *topo_ptr++ = NULL;
  198.  
  199.  
  200.    /* determine recognition units of ARTa
  201.    */
  202.    ret_code = kram_get_RecUnits_a (&topo_ptr, &ArtMap_NoOfRecUnits_a);
  203.  
  204.    if (ret_code != KRERR_NO_ERROR) {
  205.       return (ret_code);
  206.    } /*if*/
  207.  
  208.    if (ArtMap_NoOfRecUnits_a == 0) {
  209.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTa recognition");
  210.    } /*if*/
  211.  
  212.    *topo_ptr++ = NULL;
  213.  
  214.  
  215.    /* determine delay units of ARTa
  216.    */
  217.    ret_code = kram_get_DelUnits_a (&topo_ptr, &no_of_dela_units);
  218.  
  219.    if (ret_code != KRERR_NO_ERROR) {
  220.       return (ret_code);
  221.    } /*if*/
  222.  
  223.    if (no_of_dela_units != ArtMap_NoOfRecUnits_a + 3) {
  224.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTa delay");
  225.    } /*if*/
  226.  
  227.    *topo_ptr++ = NULL;
  228.  
  229.  
  230.    /* determine local reset units of ARTa
  231.    */
  232.    ret_code = kram_get_RstUnits_a (&topo_ptr, &no_of_rsta_units);
  233.  
  234.    if (ret_code != KRERR_NO_ERROR) {
  235.       return (ret_code);
  236.    } /*if*/
  237.  
  238.    if (no_of_rsta_units != ArtMap_NoOfRecUnits_a) {
  239.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTa reset");
  240.    } /*if*/
  241.  
  242.    *topo_ptr++ = NULL;
  243.  
  244.  
  245.    /* determine special units of ARTa
  246.    */
  247.    ret_code = kram_get_SpecUnits_a (&topo_ptr, &no_of_speca_units);
  248.  
  249.    if (ret_code != KRERR_NO_ERROR) {
  250.       return (ret_code);
  251.    } /*if*/
  252.  
  253.    if (no_of_speca_units != ARTMAP_NO_OF_SPECa_UNITS) {
  254.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTa special");
  255.    } /*if*/
  256.  
  257.    *topo_ptr++ = NULL;
  258.  
  259.  
  260.    /**********  determine unit types for ARTb  and insert them into topo ptr array
  261.    **********/
  262.  
  263.    /* determine input units of ARTb
  264.    */
  265.    ret_code = kram_get_InpUnits_b (&topo_ptr, &ArtMap_NoOfInpUnits_b);
  266.  
  267.    if (ret_code != KRERR_NO_ERROR) {
  268.       return (ret_code);
  269.    } /*if*/
  270.  
  271.    if (ArtMap_NoOfInpUnits_b == 0) {
  272.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTb input");
  273.    } /*if*/
  274.  
  275.    *topo_ptr++ = NULL;
  276.  
  277.  
  278.    /* determine comparison units of ARTb
  279.    */
  280.    ret_code = kram_get_CmpUnits_b (&topo_ptr, &no_of_cmpb_units);
  281.  
  282.    if (ret_code != KRERR_NO_ERROR) {
  283.       return (ret_code);
  284.    } /*if*/
  285.  
  286.    if (no_of_cmpb_units != ArtMap_NoOfInpUnits_b) {
  287.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTb comparison");
  288.    } /*if*/
  289.  
  290.    *topo_ptr++ = NULL;
  291.  
  292.  
  293.  
  294.    /* determine recognition units of ARTb
  295.    */
  296.    ret_code = kram_get_RecUnits_b (&topo_ptr, &ArtMap_NoOfRecUnits_b);
  297.  
  298.    if (ret_code != KRERR_NO_ERROR) {
  299.       return (ret_code);
  300.    } /*if*/
  301.  
  302.    if (ArtMap_NoOfRecUnits_b == 0) {
  303.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTb recognition");
  304.    } /*if*/
  305.  
  306.    *topo_ptr++ = NULL;
  307.  
  308.  
  309.    /* determine delay units of ARTb
  310.    */
  311.    ret_code = kram_get_DelUnits_b (&topo_ptr, &no_of_delb_units);
  312.  
  313.    if (ret_code != KRERR_NO_ERROR) {
  314.       return (ret_code);
  315.    } /*if*/
  316.  
  317.    if (no_of_delb_units != ArtMap_NoOfRecUnits_b + 3) {
  318.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTb delay");
  319.    } /*if*/
  320.  
  321.    *topo_ptr++ = NULL;
  322.  
  323.  
  324.    /* determine local reset units of ARTb
  325.    */
  326.    ret_code = kram_get_RstUnits_b (&topo_ptr, &no_of_rstb_units);
  327.  
  328.    if (ret_code != KRERR_NO_ERROR) {
  329.       return (ret_code);
  330.    } /*if*/
  331.  
  332.    if (no_of_rstb_units != ArtMap_NoOfRecUnits_b) {
  333.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTb reset");
  334.    } /*if*/
  335.  
  336.    *topo_ptr++ = NULL;
  337.  
  338.  
  339.    /* determine special units of ARTb
  340.    */
  341.    ret_code = kram_get_SpecUnits_b (&topo_ptr, &no_of_specb_units);
  342.  
  343.    if (ret_code != KRERR_NO_ERROR) {
  344.       return (ret_code);
  345.    } /*if*/
  346.  
  347.    if (no_of_specb_units != ARTMAP_NO_OF_SPECb_UNITS) {
  348.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("ARTb special");
  349.    } /*if*/
  350.  
  351.    *topo_ptr++ = NULL;
  352.  
  353.  
  354.  
  355.    /**********  determine unit types for MAP-Field and insert them into topo ptr array
  356.    **********/
  357.  
  358.    /* determine map units
  359.    */
  360.    ArtMap_map_layer = topo_ptr;
  361.    ret_code = kram_get_MapUnits (&topo_ptr,&no_of_map_units);
  362.  
  363.    if (ret_code != KRERR_NO_ERROR) {
  364.       return (ret_code);
  365.    } /*if*/
  366.  
  367.    if (no_of_map_units != ArtMap_NoOfRecUnits_b) {
  368.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("map");
  369.    } /*if*/
  370.  
  371.    *topo_ptr++ = NULL;
  372.  
  373.  
  374.    /* determine special units
  375.    */
  376.    ret_code = kram_get_SpecUnits (&topo_ptr, &no_of_spec_units);;
  377.  
  378.    if (ret_code != KRERR_NO_ERROR) {
  379.       return (ret_code);
  380.    } /*if*/
  381.  
  382.    if (no_of_spec_units != 10) {
  383.       TOPO_MSG_NO_OF_UNITS_IN_LAYER ("Map Field special");
  384.    } /*if*/
  385.  
  386.    *topo_ptr++ = NULL;
  387.    *topo_ptr   = NULL;  /* set second NULL pointer at the end */
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.    /* check if the logical type of really all units is determined
  396.    */
  397.    if (krart_check_undeterminedUnits ()) {
  398.       ret_code = topo_msg.error_code;
  399.       return (ret_code);
  400.    } /*if*/
  401.  
  402.  
  403.    /* Now check the topo ptr array
  404.    */
  405.    ret_code = kram_TopoPtrArray ();
  406.  
  407.    if (ret_code != KRERR_NO_ERROR) {
  408.       return (ret_code);
  409.    } /*if*/
  410.  
  411.  
  412.    /* Check the sites
  413.    */
  414.  
  415.    ret_code = kram_Sites ();
  416.  
  417.    if (ret_code != KRERR_NO_ERROR) {
  418.       return (ret_code);
  419.    } /*if*/
  420.  
  421.  
  422.    /* Check link structure
  423.    */
  424.  
  425.    topo_ptr = topo_ptr_array + 1;
  426.  
  427.    /* Check links of inpa units
  428.    */
  429.    ret_code = kram_LinksToInpUnits_a (&topo_ptr);
  430.  
  431.    if (ret_code != KRERR_NO_ERROR) {
  432.       return (ret_code);
  433.    } /*if*/
  434.  
  435.  
  436.    /* Check links of cmpa units
  437.    */
  438.    ret_code = kram_LinksToCmpUnits_a (&topo_ptr);
  439.  
  440.    if (ret_code != KRERR_NO_ERROR) {
  441.       return (ret_code);
  442.    } /*if*/
  443.  
  444.  
  445.    /* Check links of reca units
  446.    */
  447.    ret_code = kram_LinksToRecUnits_a (&topo_ptr);
  448.  
  449.    if (ret_code != KRERR_NO_ERROR) {
  450.       return (ret_code);
  451.    } /*if*/
  452.  
  453.  
  454.    /* Check links of dela units and d1a, d2a, d3a
  455.    */
  456.    ret_code = kram_LinksToDelUnits_a (&topo_ptr);
  457.  
  458.    if (ret_code != KRERR_NO_ERROR) {
  459.       return (ret_code);
  460.    } /*if*/
  461.  
  462.  
  463.    /* Check links of rsta units
  464.    */
  465.    ret_code = kram_LinksToRstUnits_a (&topo_ptr);
  466.  
  467.    if (ret_code != KRERR_NO_ERROR) {
  468.       return (ret_code);
  469.    } /*if*/
  470.  
  471.  
  472.    /* Check links of special units of ARTa
  473.    */
  474.    ret_code = kram_LinksToSpecUnits_a (&topo_ptr);
  475.  
  476.    if (ret_code != KRERR_NO_ERROR) {
  477.       return (ret_code);
  478.    } /*if*/
  479.  
  480.  
  481.    /* Check links of inpb units
  482.    */
  483.    ret_code = kram_LinksToInpUnits_b (&topo_ptr);
  484.  
  485.    if (ret_code != KRERR_NO_ERROR) {
  486.       return (ret_code);
  487.    } /*if*/
  488.  
  489.  
  490.    /* Check links of cmpb units
  491.    */
  492.    ret_code = kram_LinksToCmpUnits_b (&topo_ptr);
  493.  
  494.    if (ret_code != KRERR_NO_ERROR) {
  495.       return (ret_code);
  496.    } /*if*/
  497.  
  498.  
  499.    /* Check links of recb units
  500.    */
  501.    ret_code = kram_LinksToRecUnits_b (&topo_ptr);
  502.  
  503.    if (ret_code != KRERR_NO_ERROR) {
  504.       return (ret_code);
  505.    } /*if*/
  506.  
  507.  
  508.    /* Check links of delb units and d1b, d2b, d3b
  509.    */
  510.    ret_code = kram_LinksToDelUnits_b (&topo_ptr);
  511.  
  512.    if (ret_code != KRERR_NO_ERROR) {
  513.       return (ret_code);
  514.    } /*if*/
  515.  
  516.  
  517.    /* Check links of rstb units
  518.    */
  519.    ret_code = kram_LinksToRstUnits_b (&topo_ptr);
  520.  
  521.    if (ret_code != KRERR_NO_ERROR) {
  522.       return (ret_code);
  523.    } /*if*/
  524.  
  525.  
  526.    /* Check links of special units of ARTb
  527.    */
  528.    ret_code = kram_LinksToSpecUnits_b (&topo_ptr);
  529.  
  530.    if (ret_code != KRERR_NO_ERROR) {
  531.       return (ret_code);
  532.    } /*if*/
  533.  
  534.  
  535.    /* Check links of map units
  536.    */
  537.    ret_code = kram_LinksToMapUnits (&topo_ptr);
  538.  
  539.    if (ret_code != KRERR_NO_ERROR) {
  540.       return (ret_code);
  541.    } /*if*/
  542.  
  543.  
  544.    /* Check links of special units of MAPFIELD
  545.    */
  546.    ret_code = kram_LinksToSpecUnits (&topo_ptr);
  547.  
  548.    if (ret_code != KRERR_NO_ERROR) {
  549.       return (ret_code);
  550.    } /*if*/
  551.  
  552.  
  553.  
  554.  
  555.    /* initialize the fix weights of ARTMAP
  556.    */
  557.  
  558.    ret_code = kram_init_fix_weights ();
  559.  
  560.    return (ret_code);
  561.  
  562. } /* kram_sort () */
  563. /*___________________________________________________________________________*/
  564.  
  565.  
  566.  
  567. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  568. int   kram_getClassNo (void)
  569. {
  570.     TopoPtrArray   topo_ptr = ArtMap_map_layer;
  571.     int            i;
  572.  
  573.     /* if ARTMAP sorting wasn't performed then return negative value
  574.        to indicate mistake
  575.     */
  576.     if (topo_ptr == NULL) {
  577.        return (-1);
  578.     } /*if*/
  579.  
  580.     /* look for winning unit */
  581.     for (i = 1; (i <= ArtMap_NoOfRecUnits_b) || ((*topo_ptr)->act >= 0.9);
  582.          i++, topo_ptr++
  583.         );
  584.  
  585.     if ((i > ArtMap_NoOfRecUnits_b) && ((*topo_ptr)->act < 0.9)) {
  586.        return (-1);
  587.     } else {
  588.        return (topo_ptr - ArtMap_map_layer + 1);
  589.     } /*if*/
  590.  
  591. } /* kram_getClassNo () */
  592. /*___________________________________________________________________________*/
  593.  
  594.  
  595.  
  596. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  597. bool  kram_AllMapUnitsActive (void)
  598. {
  599.     TopoPtrArray   topo_ptr = ArtMap_map_layer;
  600.  
  601.     if (topo_ptr == NULL) {
  602.        return (FALSE);
  603.     } /*if*/
  604.  
  605.     while (*topo_ptr != NULL) {
  606.        if ((*topo_ptr)->act < 0.9) {
  607.           return (FALSE);
  608.        } /*if*/
  609.     } /*while*/
  610.  
  611.     return (TRUE);
  612.  
  613. } /* kram_AllMapUnitsActive () */
  614. /*___________________________________________________________________________*/
  615.  
  616.  
  617.  
  618. /************* functions to determine units of ARTa
  619. *************/
  620.  
  621.  
  622. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  623. static krui_err  kram_get_InpUnits_a (TopoPtrArray *topo_ptr, int *no_of_units)
  624. {
  625.    krui_err                   ret_code = KRERR_NO_ERROR;
  626.  
  627.    register struct Unit       *unit_src_ptr, *unit_trg_ptr;
  628.    register struct Site       *site_trg_ptr;
  629.    register struct Link       *link_trg_ptr;
  630.  
  631.    int                        count_links;
  632.  
  633.    /* for the inpa units it is characteristical that they have got 5
  634.       links to other units while the ones of ARTb just have 4
  635.    */
  636.  
  637.    *no_of_units = 0;
  638.    FOR_ALL_UNITS (unit_src_ptr) {
  639.  
  640.       if (IS_INPUT_UNIT (unit_src_ptr)) {
  641.  
  642.          if (UNIT_HAS_INPUTS (unit_src_ptr)) {
  643.             topo_msg.error_code = KRERR_I_UNITS_CONNECT;
  644.             topo_msg.dest_error_unit = unit_src_ptr-unit_array;
  645.             topo_msg.src_error_unit = 0;
  646.             return (topo_msg.error_code);
  647.          } /*if*/
  648.  
  649.          count_links = 0;
  650.  
  651.          FOR_ALL_UNITS (unit_trg_ptr) {
  652.  
  653.             if (UNIT_HAS_SITES (unit_trg_ptr)) {
  654.                FOR_ALL_SITES_AND_LINKS (unit_trg_ptr, site_trg_ptr, link_trg_ptr) {
  655.                   if (link_trg_ptr->to == unit_src_ptr) {
  656.                      count_links++;
  657.                   } /*if*/
  658.                } /*FOR_ALL_SITES_AND_LINKS*/
  659.             } else {
  660.                FOR_ALL_LINKS (unit_trg_ptr, link_trg_ptr) {
  661.                   if (link_trg_ptr->to == unit_src_ptr) {
  662.                      count_links++;
  663.                   } /*if*/
  664.                } /*FOR_ALL_LINKS*/
  665.             } /*if*/
  666.  
  667.          } /*FOR_ALL_UNITS*/
  668.  
  669.          if (count_links == 5) {
  670.  
  671.             if (!(CHECK_ACT_FUNC (unit_src_ptr, ARTMAP_ACTF_INPa))) {
  672.                TOPO_MSG_ACT_FUNC (unit_src_ptr);
  673.             } /*if*/
  674.  
  675.             if (!(CHECK_OUT_FUNC (unit_src_ptr, ARTMAP_OUTFUNC))) {
  676.                TOPO_MSG_OUT_FUNC (unit_src_ptr);
  677.             } /*if*/
  678.  
  679.             (*no_of_units)++;
  680.             **topo_ptr = unit_src_ptr;
  681.             unit_src_ptr->lln = ARTMAP_INPa_LAY;
  682.             (*topo_ptr)++;
  683.             unit_src_ptr->flags |= UFLAG_REFRESH;
  684.          } /*if*/
  685.  
  686.       } /*if*/
  687.  
  688.    } /*FOR_ALL_UNITS*/
  689.  
  690.    return (ret_code);
  691.  
  692. } /* kram_get_InpUnits_a () */
  693. /*___________________________________________________________________________*/
  694.  
  695.  
  696.  
  697.  
  698. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  699. static krui_err  kram_get_CmpUnits_a (TopoPtrArray *topo_ptr, int *no_of_units)
  700. {
  701.    krui_err                 ret_code  = KRERR_NO_ERROR;
  702.  
  703.    register struct Unit     *unit_ptr;
  704.    struct Unit              *unit_src_ptr;
  705.    register struct Link     *link_ptr;
  706.    struct Link              *link_src_ptr;
  707.  
  708.    bool                     is_cmpa_unit;
  709.    bool                     has_link_to_inpa;
  710.    bool                     has_link_to_other_than_inpa;
  711.  
  712.  
  713.    *no_of_units = 0;
  714.  
  715.    /* look for a reca unit */
  716.  
  717.    FOR_ALL_UNITS (unit_ptr) {
  718.  
  719.       if (!IS_SPECIAL_UNIT (unit_ptr)) {
  720.          /* we can continue the search, 'cause reca units have got
  721.             ttype special
  722.          */
  723.          continue;
  724.       } /*if*/
  725.  
  726.       /* the recognition unit is not supposed to have sites
  727.       */
  728.       if (UNIT_HAS_SITES (unit_ptr)) {
  729.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  730.       } /*if*/
  731.  
  732.  
  733.       /* unit_ptr points to a recogniton unit.
  734.          we follow the incoming links of this unit. if the source unit we
  735.          got by doing this has the following properties, this is a comparison
  736.          unit of ARTa
  737.                 - has no sites
  738.                 - has incoming link from inpa unit
  739.                 - has incoming link from other than inpa unit
  740.       */
  741.  
  742.       FOR_ALL_LINKS (unit_ptr, link_ptr) {
  743.  
  744.          unit_src_ptr = link_ptr->to;
  745.  
  746.          is_cmpa_unit                 = FALSE;
  747.          has_link_to_inpa             = FALSE;
  748.          has_link_to_other_than_inpa  = FALSE;
  749.  
  750.          if (UNIT_HAS_DIRECT_INPUTS (unit_src_ptr)) {
  751.  
  752.             FOR_ALL_LINKS (unit_src_ptr, link_src_ptr) {
  753.  
  754.                if (link_src_ptr->to->lln == ARTMAP_INPa_LAY) {
  755.                   has_link_to_inpa = TRUE;
  756.                } else {
  757.                   has_link_to_other_than_inpa = TRUE;
  758.                } /*if*/
  759.  
  760.                if (has_link_to_inpa && has_link_to_other_than_inpa) {
  761.                   is_cmpa_unit = TRUE;
  762.                   break;
  763.                } /*if*/
  764.  
  765.             } /*FOR_ALL_LINKS*/
  766.  
  767.          } /*if*/
  768.  
  769.          if (is_cmpa_unit) {
  770.  
  771.             if (!(CHECK_ACT_FUNC (unit_src_ptr, ARTMAP_ACTF_CMPa))) {
  772.                TOPO_MSG_ACT_FUNC (unit_src_ptr);
  773.             } /*if*/
  774.  
  775.             if (!(CHECK_OUT_FUNC (unit_src_ptr, ARTMAP_OUTFUNC))) {
  776.                TOPO_MSG_OUT_FUNC (unit_src_ptr);
  777.             } /*if*/
  778.  
  779.             unit_src_ptr->lln = ARTMAP_CMPa_LAY;
  780.             (*no_of_units)++;
  781.             **topo_ptr = unit_src_ptr;
  782.             unit_src_ptr->flags |= UFLAG_REFRESH;
  783.             (*topo_ptr)++;
  784.  
  785.          } /*if*/
  786.  
  787.       } /*FOR_ALL_LINKS*/
  788.  
  789.       if (*no_of_units > 0) {
  790.          /* stop searching for reca unit */
  791.          break;
  792.       } /*if*/
  793.  
  794.    } /*FOR_ALL_UNITS*/
  795.  
  796.    return (ret_code);
  797.  
  798. } /* kram_get_CmpUnits_a () */
  799. /*___________________________________________________________________________*/
  800.  
  801.  
  802.  
  803. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  804. static krui_err  kram_get_RecUnits_a (TopoPtrArray *topo_ptr, int *no_of_units)
  805. {
  806.    krui_err                   ret_code   = KRERR_NO_ERROR;
  807.  
  808.    register struct Unit       *unit_ptr;
  809.    register struct Link       *link_ptr;
  810.  
  811.    bool                       is_reca_unit;
  812.  
  813.  
  814.    *no_of_units = 0;
  815.  
  816.    /* properties of reca units:
  817.           - has no sites
  818.           - has incoming links from cmpa units
  819.    */
  820.  
  821.    FOR_ALL_UNITS (unit_ptr) {
  822.  
  823.       if (IS_SPECIAL_UNIT (unit_ptr)) {
  824.  
  825.          if (UNIT_HAS_SITES (unit_ptr)) {
  826.             TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  827.          } /*if*/
  828.  
  829.          is_reca_unit = FALSE;
  830.  
  831.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  832.  
  833.             if (link_ptr->to->lln == ARTMAP_CMPa_LAY) {
  834.                is_reca_unit = TRUE;
  835.                break;
  836.             } /*if*/
  837.  
  838.          } /*FOR_ALL_LINKS*/
  839.  
  840.          if (is_reca_unit) {
  841.  
  842.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RECa))) {
  843.                TOPO_MSG_ACT_FUNC (unit_ptr);
  844.             } /*if*/
  845.  
  846.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  847.                TOPO_MSG_OUT_FUNC (unit_ptr);
  848.             } /*if*/
  849.  
  850.             unit_ptr->lln = ARTMAP_RECa_LAY;
  851.             **topo_ptr = unit_ptr;
  852.             (*no_of_units)++;
  853.             (*topo_ptr)++;
  854.             unit_ptr->flags |= UFLAG_REFRESH;
  855.  
  856.          } /*if*/
  857.  
  858.       } /*if*/
  859.  
  860.     } /*FOR_ALL_UNITS*/
  861.  
  862.     return (ret_code);
  863.  
  864. } /* kram_get_RecUnits_a */
  865. /*___________________________________________________________________________*/
  866.  
  867.  
  868.  
  869. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  870. static krui_err  kram_get_DelUnits_a (TopoPtrArray *topo_ptr, int *no_of_units)
  871. {
  872.    krui_err                 ret_code      = KRERR_NO_ERROR;
  873.  
  874.    register struct Unit     *unit_ptr;
  875.    register struct Link     *link_ptr;
  876.    struct Link              *this_link = NULL;
  877.  
  878.    int                      count_links;
  879.    int                      no_of_dela_units = 0;
  880.    bool                     got_d1a_unit     = FALSE;
  881.    bool                     got_d2a_unit     = FALSE;
  882.    bool                     got_d3a_unit     = FALSE;
  883.  
  884.  
  885.    *no_of_units = 0;
  886.  
  887.    /* the dela units each have got just one incoming link from their
  888.       corresponding reca unit. They don't have sites.
  889.    */
  890.  
  891.    FOR_ALL_UNITS (unit_ptr) {
  892.  
  893.       if ((! (UNIT_REFRESHED (unit_ptr))) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  894.  
  895.          count_links = 0;
  896.  
  897.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  898.  
  899.             count_links++;
  900.             this_link = link_ptr;
  901.  
  902.          } /*FOR_ALL_LINKS*/
  903.  
  904.          if ((count_links == 1) && (this_link->to->lln == ARTMAP_RECa_LAY)) {
  905.  
  906.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_DELa))) {
  907.                TOPO_MSG_ACT_FUNC (unit_ptr);
  908.             } /*if*/
  909.  
  910.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  911.                TOPO_MSG_OUT_FUNC (unit_ptr);
  912.             } /*if*/
  913.  
  914.             unit_ptr->lln = ARTMAP_DELa_LAY;
  915.             unit_ptr->lun = ARTMAP_DELa_REC_UNIT;
  916.             no_of_dela_units++;
  917.             **topo_ptr = unit_ptr;
  918.             (*topo_ptr)++;
  919.             unit_ptr->flags |= UFLAG_REFRESH;
  920.  
  921.          } /*if*/
  922.  
  923.       } /*if*/
  924.  
  925.    } /*FOR_ALL_UNITS*/
  926.  
  927.  
  928.    /* now we are looking for d1a which has to have links to all dela units
  929.    */
  930.  
  931.    FOR_ALL_UNITS (unit_ptr) {
  932.  
  933.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  934.  
  935.          count_links = 0;
  936.  
  937.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  938.  
  939.             if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  940.                 (link_ptr->to->lun == ARTMAP_DELa_REC_UNIT))
  941.             {
  942.                count_links ++;
  943.             } /*if*/
  944.  
  945.          } /*FOR_ALL_LINKS*/
  946.  
  947.          if (count_links == no_of_dela_units) {
  948.  
  949.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_Da))) {
  950.                TOPO_MSG_ACT_FUNC (unit_ptr);
  951.             } /*if*/
  952.  
  953.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  954.                TOPO_MSG_OUT_FUNC (unit_ptr);
  955.             } /*if*/
  956.  
  957.             unit_ptr->lln = ARTMAP_DELa_LAY;
  958.             unit_ptr->lun = ARTMAP_D1a_UNIT;
  959.             **topo_ptr = unit_ptr;
  960.             (*topo_ptr)++;
  961.             got_d1a_unit = TRUE;
  962.             unit_ptr->flags |= UFLAG_REFRESH;
  963.  
  964.             /* Now we can break the search, 'cause we got the d1a unit */
  965.             break;
  966.  
  967.          } /*if*/
  968.  
  969.       } /*FOR_ALL_LINKS*/
  970.  
  971.    } /*FOR_ALL_UNITS*/
  972.  
  973.    if (!got_d1a_unit) {
  974.       TOPO_MSG_UNIT_MISSING ("ARTa: d1 (=d1a)");
  975.    } /*if*/
  976.  
  977.  
  978.    /* Now we are looking for the d2a unit */
  979.  
  980.    FOR_ALL_UNITS (unit_ptr) {
  981.  
  982.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  983.  
  984.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  985.  
  986.             if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  987.                 (link_ptr->to->lun == ARTMAP_D1a_UNIT)
  988.                )
  989.             {
  990.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_Da))) {
  991.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  992.                } /*if*/
  993.  
  994.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  995.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  996.                } /*if*/
  997.  
  998.                unit_ptr->lln = ARTMAP_DELa_LAY;
  999.                unit_ptr->lun = ARTMAP_D2a_UNIT;
  1000.                **topo_ptr = unit_ptr;
  1001.                (*topo_ptr)++;
  1002.                got_d2a_unit = TRUE;
  1003.                unit_ptr->flags |= UFLAG_REFRESH;
  1004.  
  1005.                /* we can break the search for the d2a unit */
  1006.                break;
  1007.             } /*if*/
  1008.  
  1009.          } /*FOR_ALL_LINKS*/
  1010.  
  1011.       } /*if*/
  1012.  
  1013.    } /*FOR_ALL_UNITS*/
  1014.  
  1015.    if (!got_d2a_unit) {
  1016.       TOPO_MSG_UNIT_MISSING ("ARTa: d2 (=d2a)");
  1017.    } /*if*/
  1018.  
  1019.  
  1020.    /* Now we are looking for the d3a unit */
  1021.  
  1022.    FOR_ALL_UNITS (unit_ptr) {
  1023.  
  1024.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  1025.  
  1026.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1027.  
  1028.             if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  1029.                 (link_ptr->to->lun == ARTMAP_D2a_UNIT)
  1030.                )
  1031.             {
  1032.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_Da))) {
  1033.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1034.                } /*if*/
  1035.  
  1036.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1037.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1038.                } /*if*/
  1039.  
  1040.                unit_ptr->lln = ARTMAP_DELa_LAY;
  1041.                unit_ptr->lun = ARTMAP_D3a_UNIT;
  1042.                **topo_ptr = unit_ptr;
  1043.                (*topo_ptr)++;
  1044.                got_d3a_unit = TRUE;
  1045.                unit_ptr->flags |= UFLAG_REFRESH;
  1046.  
  1047.                /* we can break the search for the d3a unit */
  1048.                break;
  1049.             } /*if*/
  1050.  
  1051.          } /*FOR_ALL_LINKS*/
  1052.  
  1053.       } /*if*/
  1054.  
  1055.    } /*FOR_ALL_UNITS*/
  1056.  
  1057.    if (!got_d3a_unit) {
  1058.       TOPO_MSG_UNIT_MISSING ("ARTa: d3 (=d3a)");
  1059.    } /*if*/
  1060.  
  1061.    *no_of_units = no_of_dela_units + 3;
  1062.  
  1063.    return (ret_code);
  1064.  
  1065. } /* kram_get_DelUnits_a () */
  1066. /*___________________________________________________________________________*/
  1067.  
  1068.  
  1069.  
  1070. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1071. static krui_err  kram_get_RstUnits_a (TopoPtrArray *topo_ptr, int *no_of_units)
  1072. {
  1073.    krui_err                 ret_code   = KRERR_NO_ERROR;
  1074.  
  1075.    register struct Unit     *unit_ptr;
  1076.    register struct Site     *site_ptr;
  1077.    register struct Link     *link_ptr;
  1078.  
  1079.    bool                     has_link_to_itself,
  1080.                             has_link_to_dela_unit;
  1081.  
  1082.    /* each rsta unit has got sites, a link to itself, one from a dela unit
  1083.       and one from the rga unit which wasn't determined yet.
  1084.    */
  1085.  
  1086.    FOR_ALL_UNITS (unit_ptr) {
  1087.  
  1088.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_SITES (unit_ptr))) {
  1089.  
  1090.          has_link_to_itself = FALSE;
  1091.          has_link_to_dela_unit = FALSE;
  1092.  
  1093.          FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  1094.  
  1095.             if (link_ptr->to == unit_ptr) {
  1096.                has_link_to_itself = TRUE;
  1097.             } /*if*/
  1098.  
  1099.             if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  1100.                 (link_ptr->to->lun == ARTMAP_DELa_REC_UNIT)
  1101.                )
  1102.             {
  1103.                has_link_to_dela_unit = TRUE;
  1104.             } /*if*/
  1105.  
  1106.          } /*FOR_ALL_SITES_AND_LINKS*/
  1107.  
  1108.          if (has_link_to_itself && has_link_to_dela_unit) {
  1109.  
  1110.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RSTa))) {
  1111.                 TOPO_MSG_ACT_FUNC (unit_ptr);
  1112.             } /*if*/
  1113.  
  1114.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1115.                  TOPO_MSG_OUT_FUNC (unit_ptr);
  1116.             } /*if*/
  1117.  
  1118.             unit_ptr->lln = ARTMAP_RSTa_LAY;
  1119.             (*no_of_units)++;
  1120.             **topo_ptr = unit_ptr;
  1121.             (*topo_ptr)++;
  1122.             unit_ptr->flags |= UFLAG_REFRESH;
  1123.  
  1124.          } /*if*/
  1125.  
  1126.       } /*if*/
  1127.  
  1128.    } /*FOR_ALL_UNITS*/
  1129.  
  1130.    return (ret_code);
  1131.  
  1132. } /* kram_get_RstUnits_a () */
  1133. /*___________________________________________________________________________*/
  1134.  
  1135.  
  1136. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1137. static krui_err  kram_get_SpecUnits_a (TopoPtrArray *topo_ptr, int *no_of_units)
  1138. {
  1139.    krui_err                ret_code  = KRERR_NO_ERROR;
  1140.  
  1141.    register struct Unit     *unit_ptr;
  1142.    register struct Site     *site_ptr;
  1143.    register struct Link     *link_ptr;
  1144.  
  1145.    TopoPtrArray             topo_spec_ptr = *topo_ptr;
  1146.  
  1147.    bool                     got_g1a_unit    = FALSE;
  1148.    bool                     got_ria_unit    = FALSE;
  1149.    bool                     got_rca_unit    = FALSE;
  1150.    bool                     got_rga_unit    = FALSE;
  1151.    bool                     got_cla_unit    = FALSE;
  1152.    bool                     got_nca_unit    = FALSE;
  1153.    bool                     got_rhoa_unit   = FALSE;
  1154.    bool                     got_g2a_unit    = FALSE;
  1155.  
  1156.    bool                     links_to_rsta_units,
  1157.                             links_to_d3a_unit,
  1158.                             links_to_reca_units,
  1159.                             links_to_cmpa_units,
  1160.                             links_to_inpa_units;
  1161.  
  1162.  
  1163.    *no_of_units = 0;
  1164.  
  1165.    /* looking for special units of ARTa */
  1166.  
  1167.    FOR_ALL_UNITS (unit_ptr) {
  1168.  
  1169.       if ( (!(UNIT_REFRESHED (unit_ptr))) &&
  1170.            (!got_g1a_unit || !got_ria_unit || !got_rca_unit ||
  1171.             !got_cla_unit || !got_nca_unit || !got_g2a_unit
  1172.            )
  1173.          )
  1174.       {
  1175.  
  1176.          if (UNIT_HAS_SITES (unit_ptr)) {
  1177.  
  1178.  
  1179.             /* if a unit with sites does have links from inpa units
  1180.                and reca units this can only be the g1a unit
  1181.             */
  1182.             links_to_reca_units = FALSE;
  1183.             links_to_inpa_units = FALSE;
  1184.             links_to_cmpa_units = FALSE;
  1185.  
  1186.             FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  1187.  
  1188.                switch (link_ptr->to->lln) {
  1189.                case ARTMAP_RECa_LAY:
  1190.                   links_to_reca_units = TRUE;
  1191.                   break;
  1192.                case ARTMAP_INPa_LAY:
  1193.                   links_to_inpa_units = TRUE;
  1194.                   break;
  1195.                case ARTMAP_CMPa_LAY:
  1196.                   links_to_cmpa_units = TRUE;
  1197.                   break;
  1198.                } /*switch*/
  1199.  
  1200.                if ((links_to_reca_units && links_to_inpa_units) ||
  1201.                    (links_to_reca_units && !links_to_cmpa_units)
  1202.                   )
  1203.                {
  1204.                   /* we found the g1a or the ria unit */
  1205.                   break;
  1206.                } /*if*/
  1207.  
  1208.             } /*FOR_ALL_SITES_AND_LINKS*/
  1209.  
  1210.             if (links_to_reca_units && links_to_inpa_units) {
  1211.  
  1212.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_G1a))) {
  1213.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1214.                } /*if*/
  1215.  
  1216.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1217.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1218.                } /*if*/
  1219.  
  1220.                unit_ptr->lln = ARTMAP_SPECa_LAY;
  1221.                unit_ptr->lun = ARTMAP_G1a_UNIT;
  1222.                (*no_of_units)++;
  1223.                *(topo_spec_ptr + 2) = unit_ptr;
  1224.                got_g1a_unit = TRUE;
  1225.                unit_ptr->flags |= UFLAG_REFRESH;
  1226.                (*topo_ptr)++;
  1227.  
  1228.             } else {
  1229.  
  1230.                if (links_to_inpa_units && !links_to_cmpa_units) {
  1231.  
  1232.                   /* if there are links to the inpa units but none to the
  1233.                      reca units then we found the ria unit
  1234.                   */
  1235.                   if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RIa))) {
  1236.                      TOPO_MSG_ACT_FUNC (unit_ptr);
  1237.                   } /*if*/
  1238.  
  1239.                   if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1240.                       TOPO_MSG_OUT_FUNC (unit_ptr);
  1241.                   } /*if*/
  1242.  
  1243.                   unit_ptr->lln = ARTMAP_SPECa_LAY;
  1244.                   unit_ptr->lun = ARTMAP_RIa_UNIT;
  1245.                   (*no_of_units)++;
  1246.                   *(topo_spec_ptr + 3) = unit_ptr;
  1247.                   got_ria_unit = TRUE;
  1248.                   unit_ptr->flags |= UFLAG_REFRESH;
  1249.                   (*topo_ptr)++;
  1250.  
  1251.                } /*if*/
  1252.  
  1253.             } /*if*/
  1254.  
  1255.          } else {
  1256.  
  1257.             /* unit has direct inputs */
  1258.  
  1259.             links_to_rsta_units = FALSE;
  1260.             links_to_d3a_unit   = FALSE;
  1261.             links_to_cmpa_units = FALSE;
  1262.             links_to_inpa_units = FALSE;
  1263.  
  1264.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1265.  
  1266.                switch (link_ptr->to->lln) {
  1267.                case ARTMAP_INPa_LAY:
  1268.                   links_to_inpa_units = TRUE;
  1269.                   break;
  1270.                case ARTMAP_CMPa_LAY:
  1271.                   links_to_cmpa_units = TRUE;
  1272.                   break;
  1273.                case ARTMAP_DELa_LAY:
  1274.                   if (link_ptr->to->lun == ARTMAP_D3a_UNIT) {
  1275.                      links_to_d3a_unit = TRUE;
  1276.                   } /*if*/
  1277.                   break;
  1278.                 case ARTMAP_RSTa_LAY:
  1279.                    links_to_rsta_units = TRUE;
  1280.                    break;
  1281.                 } /*switch*/
  1282.  
  1283.             } /*FOR_ALL_LINKS*/
  1284.  
  1285.             if (links_to_inpa_units && !got_g2a_unit) {
  1286.  
  1287.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_G2a))) {
  1288.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1289.                } /*if*/
  1290.  
  1291.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1292.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1293.                } /*if*/
  1294.  
  1295.                unit_ptr->lln = ARTMAP_SPECa_LAY;
  1296.                unit_ptr->lun = ARTMAP_G2a_UNIT;
  1297.                (*no_of_units)++;
  1298.                *(topo_spec_ptr + 7) = unit_ptr;
  1299.                (*topo_ptr)++;
  1300.                unit_ptr->flags |= UFLAG_REFRESH;
  1301.                got_g2a_unit = TRUE;
  1302.                continue;
  1303.             } /*if*/
  1304.  
  1305.  
  1306.             if (links_to_cmpa_units && !links_to_inpa_units &&
  1307.                 !got_rca_unit
  1308.                )
  1309.             {
  1310.  
  1311.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RCa))) {
  1312.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1313.                } /*if*/
  1314.  
  1315.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1316.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1317.                } /*if*/
  1318.  
  1319.                unit_ptr->lln = ARTMAP_SPECa_LAY;
  1320.                unit_ptr->lun = ARTMAP_RCa_UNIT;
  1321.                (*no_of_units)++;
  1322.                *(topo_spec_ptr + 4) = unit_ptr;
  1323.                (*topo_ptr)++;
  1324.                unit_ptr->flags |= UFLAG_REFRESH;
  1325.                got_rca_unit = TRUE;
  1326.                continue;
  1327.  
  1328.             } /*if*/
  1329.  
  1330.  
  1331.             if (links_to_d3a_unit && !got_cla_unit) {
  1332.  
  1333.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_CLa))) {
  1334.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1335.                } /*if*/
  1336.  
  1337.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1338.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1339.                } /*if*/
  1340.  
  1341.                unit_ptr->lln = ARTMAP_SPECa_LAY;
  1342.                unit_ptr->lun = ARTMAP_CLa_UNIT;
  1343.                (*no_of_units)++;
  1344.                *topo_spec_ptr = unit_ptr;
  1345.                (*topo_ptr)++;
  1346.                unit_ptr->flags |= UFLAG_REFRESH;
  1347.                got_cla_unit = TRUE;
  1348.                continue;
  1349.  
  1350.             } /*if*/
  1351.  
  1352.  
  1353.             if (links_to_rsta_units && !links_to_cmpa_units &&
  1354.                 !got_nca_unit
  1355.                )
  1356.             {
  1357.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_NCa))) {
  1358.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1359.                } /*if*/
  1360.  
  1361.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1362.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1363.                } /*if*/
  1364.  
  1365.                unit_ptr->lln = ARTMAP_SPECa_LAY;
  1366.                unit_ptr->lun = ARTMAP_NCa_UNIT;
  1367.                (*no_of_units)++;
  1368.                *(topo_spec_ptr + 1) = unit_ptr;
  1369.                (*topo_ptr)++;
  1370.                unit_ptr->flags |= UFLAG_REFRESH;
  1371.                got_nca_unit = TRUE;
  1372.                continue;
  1373.  
  1374.             } /*if*/
  1375.  
  1376.          } /*if*/
  1377.  
  1378.       } /*if*/
  1379.  
  1380.    } /*FOR_ALL_UNITS*/
  1381.  
  1382.  
  1383.    /* the rga and the rhoa unit remain to be determined */
  1384.  
  1385.    FOR_ALL_UNITS (unit_ptr) {
  1386.  
  1387.       if (!(UNIT_REFRESHED (unit_ptr))) {
  1388.  
  1389.          /* looking for rga unit */
  1390.  
  1391.          if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  1392.  
  1393.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1394.  
  1395.                if ((link_ptr->to->lln == ARTMAP_SPECa_LAY) &&
  1396.                    (link_ptr->to->lun == ARTMAP_RIa_UNIT)
  1397.                   )
  1398.                {
  1399.                   if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RGa))) {
  1400.                      TOPO_MSG_ACT_FUNC (unit_ptr);
  1401.                   } /*if*/
  1402.  
  1403.                   if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1404.                      TOPO_MSG_OUT_FUNC (unit_ptr);
  1405.                   } /*if*/
  1406.  
  1407.                   /* this is the rga unit */
  1408.                   unit_ptr->lln = ARTMAP_SPECa_LAY;
  1409.                   unit_ptr->lun = ARTMAP_RGa_UNIT;
  1410.                   (*no_of_units)++;
  1411.                   *(topo_spec_ptr + 5) = unit_ptr;
  1412.                   got_rga_unit =TRUE;
  1413.                   unit_ptr->flags |= UFLAG_REFRESH;
  1414.                   (*topo_ptr)++;
  1415.                   break;
  1416.  
  1417.                } /*if*/
  1418.  
  1419.             } /*FOR_ALL_LINKS*/
  1420.  
  1421.          } /*if*/
  1422.  
  1423.       } else {
  1424.  
  1425.          /* looking for rhoa unit via ria */
  1426.  
  1427.          if ((unit_ptr->lln == ARTMAP_SPECa_LAY) &&
  1428.              (unit_ptr->lun == ARTMAP_RIa_UNIT)
  1429.             )
  1430.          {
  1431.              FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  1432.  
  1433.                 if (link_ptr->to->lln != ARTMAP_INPa_LAY) {
  1434.  
  1435.                    if (!(CHECK_ACT_FUNC (link_ptr->to, ARTMAP_ACTF_RHOa))) {
  1436.                       TOPO_MSG_ACT_FUNC (link_ptr->to);
  1437.                    } /*if*/
  1438.  
  1439.                    if (!(CHECK_OUT_FUNC (link_ptr->to, ARTMAP_OUTFUNC))) {
  1440.                       TOPO_MSG_OUT_FUNC (link_ptr->to);
  1441.                    } /*if*/
  1442.  
  1443.                    /* the link_ptr->to unit is the rhoa unit */
  1444.  
  1445.                    link_ptr->to->lln = ARTMAP_SPECa_LAY;
  1446.                    link_ptr->to->lun = ARTMAP_RHOa_UNIT;
  1447.                    (*no_of_units)++;
  1448.                    *(topo_spec_ptr + 6) = link_ptr->to;
  1449.                    (*topo_ptr)++;
  1450.                    got_rhoa_unit = TRUE;
  1451.                    link_ptr->to->flags |= UFLAG_REFRESH;
  1452.                    break;
  1453.  
  1454.                 } /*if*/
  1455.  
  1456.              } /*FOR_ALL_SITES_AND_LINKS*/
  1457.  
  1458.           } /*if*/
  1459.  
  1460.        } /*if*/
  1461.  
  1462.        if (got_rga_unit && got_rhoa_unit) {
  1463.           break;
  1464.        } /*if*/
  1465.  
  1466.    } /*FOR_ALL_UNITS*/
  1467.  
  1468.    if (!got_cla_unit) {
  1469.       TOPO_MSG_UNIT_MISSING ("ARTa: cl (=cla)");
  1470.    } /*if*/
  1471.  
  1472.    if (!got_nca_unit) {
  1473.       TOPO_MSG_UNIT_MISSING ("ARTa: nc (=nca)");
  1474.    } /*if*/
  1475.  
  1476.    if (!got_ria_unit) {
  1477.       TOPO_MSG_UNIT_MISSING ("ARTa: ri (=ria)");
  1478.    } /*if*/
  1479.  
  1480.    if (!got_rca_unit) {
  1481.       TOPO_MSG_UNIT_MISSING ("ARTa: rc (=rca)");
  1482.    } /*if*/
  1483.  
  1484.    if (!got_rga_unit) {
  1485.       TOPO_MSG_UNIT_MISSING ("ARTa: rg (=rga)");
  1486.    } /*if*/
  1487.  
  1488.    if (!got_g1a_unit) {
  1489.       TOPO_MSG_UNIT_MISSING ("ARTa: g1 (=g1a)");
  1490.    } /*if*/
  1491.  
  1492.    if (!got_rhoa_unit) {
  1493.       TOPO_MSG_UNIT_MISSING ("ARTa: rho (=rhoa)");
  1494.    } /*if*/
  1495.  
  1496.    if (!got_g2a_unit) {
  1497.       TOPO_MSG_UNIT_MISSING ("ARTa: g2 (=g2a)");
  1498.    } /*if*/
  1499.  
  1500.  
  1501.    return (ret_code);
  1502.  
  1503. } /* kram_get_SpecUnits_a () */
  1504. /*___________________________________________________________________________*/
  1505.  
  1506.  
  1507.  
  1508.  
  1509. /*************** functions to determine units of ARTb
  1510. ***************/
  1511.  
  1512.  
  1513. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1514. static krui_err  kram_get_InpUnits_b (TopoPtrArray *topo_ptr, int *no_of_units)
  1515. {
  1516.    krui_err                   ret_code = KRERR_NO_ERROR;
  1517.  
  1518.    register struct Unit       *unit_src_ptr, *unit_trg_ptr;
  1519.    register struct Site       *site_trg_ptr;
  1520.    register struct Link       *link_trg_ptr;
  1521.  
  1522.    int                        count_links;
  1523.  
  1524.    /* for the inpb units it is characteristical that they have got 2
  1525.       links to other units while the ones of ARTa have 3
  1526.    */
  1527.  
  1528.    *no_of_units = 0;
  1529.    FOR_ALL_UNITS (unit_src_ptr) {
  1530.  
  1531.       if (IS_INPUT_UNIT (unit_src_ptr)) {
  1532.  
  1533.          if (UNIT_HAS_INPUTS (unit_src_ptr)) {
  1534.             topo_msg.error_code = KRERR_I_UNITS_CONNECT;
  1535.             topo_msg.dest_error_unit = unit_src_ptr-unit_array;
  1536.             topo_msg.src_error_unit = 0;
  1537.             return (topo_msg.error_code);
  1538.          } /*if*/
  1539.  
  1540.          count_links = 0;
  1541.  
  1542.          FOR_ALL_UNITS (unit_trg_ptr) {
  1543.  
  1544.             if (UNIT_HAS_SITES (unit_trg_ptr)) {
  1545.                FOR_ALL_SITES_AND_LINKS (unit_trg_ptr, site_trg_ptr, link_trg_ptr) {
  1546.                   if (link_trg_ptr->to == unit_src_ptr) {
  1547.                      count_links++;
  1548.                   } /*if*/
  1549.                } /*FOR_ALL_SITES_AND_LINKS*/
  1550.             } else {
  1551.                FOR_ALL_LINKS (unit_trg_ptr, link_trg_ptr) {
  1552.                   if (link_trg_ptr->to == unit_src_ptr) {
  1553.                      count_links++;
  1554.                   } /*if*/
  1555.                } /*FOR_ALL_LINKS*/
  1556.             } /*if*/
  1557.  
  1558.          } /*FOR_ALL_UNITS*/
  1559.  
  1560.          if (count_links == 4) {
  1561.  
  1562.             if (!(CHECK_ACT_FUNC (unit_src_ptr, ARTMAP_ACTF_INPb))) {
  1563.                TOPO_MSG_ACT_FUNC (unit_src_ptr);
  1564.             } /*if*/
  1565.  
  1566.             if (!(CHECK_OUT_FUNC (unit_src_ptr, ARTMAP_OUTFUNC))) {
  1567.                TOPO_MSG_OUT_FUNC (unit_src_ptr);
  1568.             } /*if*/
  1569.  
  1570.             (*no_of_units)++;
  1571.             **topo_ptr = unit_src_ptr;
  1572.             unit_src_ptr->lln = ARTMAP_INPb_LAY;
  1573.             (*topo_ptr)++;
  1574.             unit_src_ptr->flags |= UFLAG_REFRESH;
  1575.  
  1576.          } /*if*/
  1577.  
  1578.       } /*if*/
  1579.  
  1580.    } /*FOR_ALL_UNITS*/
  1581.  
  1582.    return (ret_code);
  1583.  
  1584. } /* kram_get_InpUnits_b () */
  1585. /*___________________________________________________________________________*/
  1586.  
  1587.  
  1588.  
  1589.  
  1590. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1591. static krui_err  kram_get_CmpUnits_b (TopoPtrArray *topo_ptr, int *no_of_units)
  1592. {
  1593.    krui_err                 ret_code  = KRERR_NO_ERROR;
  1594.  
  1595.    register struct Unit     *unit_ptr;
  1596.    struct Unit              *unit_src_ptr;
  1597.    register struct Link     *link_ptr;
  1598.    struct Link              *link_src_ptr;
  1599.  
  1600.    bool                     is_cmpb_unit;
  1601.    bool                     has_link_to_inpb;
  1602.    bool                     has_link_to_other_than_inpb;
  1603.  
  1604.  
  1605.    *no_of_units = 0;
  1606.  
  1607.    /* look for a recb unit */
  1608.  
  1609.    FOR_ALL_UNITS (unit_ptr) {
  1610.  
  1611.       if (!IS_SPECIAL_UNIT (unit_ptr)) {
  1612.          continue;
  1613.       } /*if*/
  1614.  
  1615.       /* the recognition unit is not supposed to have sites
  1616.       */
  1617.       if (UNIT_HAS_SITES (unit_ptr)) {
  1618.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  1619.       } /*if*/
  1620.  
  1621.  
  1622.       /* unit_ptr points to a recogniton unit.
  1623.          we follow the incoming links of this unit. if the source unit we
  1624.          got by doing this has the following properties, this is a comparison
  1625.          unit of ARTb
  1626.                 - has no sites
  1627.                 - has incoming link from inpb unit
  1628.       */
  1629.  
  1630.       FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1631.  
  1632.          unit_src_ptr = link_ptr->to;
  1633.  
  1634.          is_cmpb_unit                = FALSE;
  1635.          has_link_to_inpb            = FALSE;
  1636.          has_link_to_other_than_inpb = FALSE;
  1637.  
  1638.          if (UNIT_HAS_DIRECT_INPUTS (unit_src_ptr)) {
  1639.  
  1640.             FOR_ALL_LINKS (unit_src_ptr, link_src_ptr) {
  1641.  
  1642.                if (link_src_ptr->to->lln == ARTMAP_INPb_LAY) {
  1643.                   has_link_to_inpb = TRUE;
  1644.                } else {
  1645.                   has_link_to_other_than_inpb = TRUE;
  1646.                } /*if*/
  1647.  
  1648.                if (has_link_to_inpb && has_link_to_other_than_inpb) {
  1649.                   is_cmpb_unit = TRUE;
  1650.                   break;
  1651.                } /*if*/
  1652.  
  1653.             } /*FOR_ALL_LINKS*/
  1654.  
  1655.          } /*if*/
  1656.  
  1657.          if (is_cmpb_unit) {
  1658.  
  1659.             if (!(CHECK_ACT_FUNC (unit_src_ptr, ARTMAP_ACTF_CMPb))) {
  1660.                TOPO_MSG_ACT_FUNC (unit_src_ptr);
  1661.             } /*if*/
  1662.  
  1663.             if (!(CHECK_OUT_FUNC (unit_src_ptr, ARTMAP_OUTFUNC))) {
  1664.                TOPO_MSG_OUT_FUNC (unit_src_ptr);
  1665.             } /*if*/
  1666.  
  1667.             unit_src_ptr->lln = ARTMAP_CMPb_LAY;
  1668.             (*no_of_units)++;
  1669.             **topo_ptr = unit_src_ptr;
  1670.             unit_src_ptr->flags |= UFLAG_REFRESH;
  1671.             (*topo_ptr)++;
  1672.  
  1673.          } /*if*/
  1674.  
  1675.       } /*FOR_ALL_LINKS*/
  1676.  
  1677.       if (*no_of_units > 0) {
  1678.          /* stop searching for reca unit */
  1679.          break;
  1680.       } /*if*/
  1681.  
  1682.    } /*FOR_ALL_UNITS*/
  1683.  
  1684.    return (ret_code);
  1685.  
  1686. } /* kram_get_CmpUnits_b () */
  1687. /*___________________________________________________________________________*/
  1688.  
  1689.  
  1690.  
  1691. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1692. static krui_err  kram_get_RecUnits_b (TopoPtrArray *topo_ptr, int *no_of_units)
  1693. {
  1694.    krui_err                   ret_code   = KRERR_NO_ERROR;
  1695.  
  1696.    register struct Unit       *unit_ptr;
  1697.    register struct Link       *link_ptr;
  1698.  
  1699.    bool                       is_recb_unit;
  1700.  
  1701.  
  1702.    *no_of_units = 0;
  1703.  
  1704.    /* properties of recb units:
  1705.           - has no sites
  1706.           - has incoming links from cmpb units
  1707.    */
  1708.  
  1709.    FOR_ALL_UNITS (unit_ptr) {
  1710.  
  1711.       if (IS_SPECIAL_UNIT (unit_ptr)) {
  1712.  
  1713.          if (UNIT_HAS_SITES (unit_ptr)) {
  1714.             TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  1715.          } /*if*/
  1716.  
  1717.          is_recb_unit = FALSE;
  1718.  
  1719.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1720.  
  1721.             if (link_ptr->to->lln == ARTMAP_CMPb_LAY) {
  1722.                is_recb_unit = TRUE;
  1723.                break;
  1724.             } /*if*/
  1725.  
  1726.          } /*FOR_ALL_LINKS*/
  1727.  
  1728.          if (is_recb_unit) {
  1729.  
  1730.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RECb))) {
  1731.                TOPO_MSG_ACT_FUNC (unit_ptr);
  1732.             } /*if*/
  1733.  
  1734.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1735.                TOPO_MSG_OUT_FUNC (unit_ptr);
  1736.             } /*if*/
  1737.  
  1738.             unit_ptr->lln = ARTMAP_RECb_LAY;
  1739.             **topo_ptr = unit_ptr;
  1740.             (*no_of_units)++;
  1741.             (*topo_ptr)++;
  1742.             unit_ptr->flags |= UFLAG_REFRESH;
  1743.  
  1744.          } /*if*/
  1745.  
  1746.       } /*if*/
  1747.  
  1748.     } /*FOR_ALL_UNITS*/
  1749.  
  1750.     return (ret_code);
  1751.  
  1752. } /* kram_get_RecUnits_b */
  1753. /*___________________________________________________________________________*/
  1754.  
  1755.  
  1756.  
  1757. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1758. static krui_err  kram_get_DelUnits_b (TopoPtrArray *topo_ptr, int *no_of_units)
  1759. {
  1760.    krui_err                 ret_code      = KRERR_NO_ERROR;
  1761.  
  1762.    register struct Unit     *unit_ptr;
  1763.    register struct Link     *link_ptr;
  1764.  
  1765.    int                      count_links;
  1766.    int                      no_of_delb_units = 0;
  1767.    bool                     has_link_to_recb_unit;
  1768.    bool                     got_d1b_unit     = FALSE;
  1769.    bool                     got_d2b_unit     = FALSE;
  1770.    bool                     got_d3b_unit     = FALSE;
  1771.  
  1772.  
  1773.    *no_of_units = 0;
  1774.  
  1775.    /* the delb units each have got just two incoming links, one of which
  1776.       is from their corresponding reca unit. They don't have sites.
  1777.    */
  1778.  
  1779.    FOR_ALL_UNITS (unit_ptr) {
  1780.  
  1781.       if ((! (UNIT_REFRESHED (unit_ptr))) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  1782.  
  1783.          count_links = 0;
  1784.          has_link_to_recb_unit = FALSE;
  1785.  
  1786.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1787.  
  1788.             count_links++;
  1789.             if (link_ptr->to->lln == ARTMAP_RECb_LAY) {
  1790.                has_link_to_recb_unit = TRUE;
  1791.             } /*if*/
  1792.  
  1793.          } /*FOR_ALL_LINKS*/
  1794.  
  1795.          if ((count_links == 2) && (has_link_to_recb_unit)) {
  1796.  
  1797.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_DELb))) {
  1798.               TOPO_MSG_ACT_FUNC (unit_ptr);
  1799.             } /*if*/
  1800.  
  1801.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1802.                TOPO_MSG_OUT_FUNC (unit_ptr);
  1803.             } /*if*/
  1804.  
  1805.             unit_ptr->lln = ARTMAP_DELb_LAY;
  1806.             unit_ptr->lun = ARTMAP_DELb_REC_UNIT;
  1807.             no_of_delb_units++;
  1808.             **topo_ptr = unit_ptr;
  1809.             (*topo_ptr)++;
  1810.             unit_ptr->flags |= UFLAG_REFRESH;
  1811.  
  1812.          } /*if*/
  1813.  
  1814.       } /*if*/
  1815.  
  1816.    } /*FOR_ALL_UNITS*/
  1817.  
  1818.  
  1819.    /* now we are looking for d1b which has to have links to all delb units
  1820.    */
  1821.  
  1822.    FOR_ALL_UNITS (unit_ptr) {
  1823.  
  1824.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  1825.  
  1826.          count_links = 0;
  1827.  
  1828.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1829.  
  1830.             if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  1831.                 (link_ptr->to->lun == ARTMAP_DELb_REC_UNIT))
  1832.             {
  1833.                count_links ++;
  1834.             } /*if*/
  1835.  
  1836.          } /*FOR_ALL_LINKS*/
  1837.  
  1838.          if (count_links == no_of_delb_units) {
  1839.  
  1840.             /* in this case we don't really check the Activation and
  1841.                output function, we use it to detemine the correct unit
  1842.                (d1b) 'cause the d1 unit has the same properties as
  1843.                d1b except its activation function.
  1844.             */
  1845.             if ((CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_Db)) &&
  1846.                 (CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))
  1847.                )
  1848.             {
  1849.                unit_ptr->lln = ARTMAP_DELb_LAY;
  1850.                unit_ptr->lun = ARTMAP_D1b_UNIT;
  1851.                **topo_ptr = unit_ptr;
  1852.                (*topo_ptr)++;
  1853.                got_d1b_unit = TRUE;
  1854.                unit_ptr->flags |= UFLAG_REFRESH;
  1855.  
  1856.                /* Now we can break the search, 'cause we got the d1b unit */
  1857.                break;
  1858.  
  1859.             } /*if*/
  1860.  
  1861.          } /*if*/
  1862.  
  1863.       } /*if*/
  1864.  
  1865.    } /*FOR_ALL_UNITS*/
  1866.  
  1867.    if (!got_d1b_unit) {
  1868.       TOPO_MSG_UNIT_MISSING ("ARTb: d1 (=d1b)");
  1869.    } /*if*/
  1870.  
  1871.  
  1872.    /* Now we are looking for the d2b unit */
  1873.  
  1874.    FOR_ALL_UNITS (unit_ptr) {
  1875.  
  1876.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  1877.  
  1878.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1879.  
  1880.             if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  1881.                 (link_ptr->to->lun == ARTMAP_D1b_UNIT)
  1882.                )
  1883.             {
  1884.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_Db))) {
  1885.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1886.                } /*if*/
  1887.  
  1888.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1889.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1890.                } /*if*/
  1891.  
  1892.                unit_ptr->lln = ARTMAP_DELb_LAY;
  1893.                unit_ptr->lun = ARTMAP_D2b_UNIT;
  1894.                **topo_ptr = unit_ptr;
  1895.                (*topo_ptr)++;
  1896.                got_d2b_unit = TRUE;
  1897.                unit_ptr->flags |= UFLAG_REFRESH;
  1898.  
  1899.                /* we can break the search for the d2b unit */
  1900.                break;
  1901.  
  1902.             } /*if*/
  1903.  
  1904.          } /*FOR_ALL_LINKS*/
  1905.  
  1906.       } /*if*/
  1907.  
  1908.    } /*FOR_ALL_UNITS*/
  1909.  
  1910.    if (!got_d2b_unit) {
  1911.       TOPO_MSG_UNIT_MISSING ("ARTb: d2 (=d2b)");
  1912.    } /*if*/
  1913.  
  1914.  
  1915.    /* Now we are looking for the d3b unit */
  1916.  
  1917.    FOR_ALL_UNITS (unit_ptr) {
  1918.  
  1919.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  1920.  
  1921.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  1922.  
  1923.             if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  1924.                 (link_ptr->to->lun == ARTMAP_D2b_UNIT)
  1925.                )
  1926.             {
  1927.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_Db))) {
  1928.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  1929.                } /*if*/
  1930.  
  1931.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  1932.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  1933.                } /*if*/
  1934.  
  1935.                unit_ptr->lln = ARTMAP_DELb_LAY;
  1936.                unit_ptr->lun = ARTMAP_D3b_UNIT;
  1937.                **topo_ptr = unit_ptr;
  1938.                (*topo_ptr)++;
  1939.                got_d3b_unit = TRUE;
  1940.                unit_ptr->flags |= UFLAG_REFRESH;
  1941.  
  1942.                /* we can break the search for the d3b unit */
  1943.                break;
  1944.  
  1945.             } /*if*/
  1946.  
  1947.          } /*FOR_ALL_LINKS*/
  1948.  
  1949.       } /*if*/
  1950.  
  1951.    } /*FOR_ALL_UNITS*/
  1952.  
  1953.    if (!got_d3b_unit) {
  1954.       TOPO_MSG_UNIT_MISSING ("ARTb: d3 (=d3b)");
  1955.    } /*if*/
  1956.  
  1957.  
  1958.    *no_of_units = no_of_delb_units + 3;
  1959.  
  1960.    return (ret_code);
  1961.  
  1962. } /* kram_get_DelUnits_b () */
  1963. /*___________________________________________________________________________*/
  1964.  
  1965.  
  1966.  
  1967. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  1968. static krui_err  kram_get_RstUnits_b (TopoPtrArray *topo_ptr, int *no_of_units)
  1969. {
  1970.    krui_err                 ret_code   = KRERR_NO_ERROR;
  1971.  
  1972.    register struct Unit     *unit_ptr;
  1973.    register struct Site     *site_ptr;
  1974.    register struct Link     *link_ptr;
  1975.  
  1976.    bool                     has_link_to_itself,
  1977.                             has_link_to_delb_unit;
  1978.  
  1979.    /* each rstb unit has got sites, a link to itself, one from a delb unit
  1980.       and one from the rgb unit which wasn't determined yet.
  1981.    */
  1982.  
  1983.    FOR_ALL_UNITS (unit_ptr) {
  1984.  
  1985.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_SITES (unit_ptr))) {
  1986.  
  1987.          has_link_to_itself = FALSE;
  1988.          has_link_to_delb_unit = FALSE;
  1989.  
  1990.          FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  1991.  
  1992.             if (link_ptr->to == unit_ptr) {
  1993.                has_link_to_itself = TRUE;
  1994.             } /*if*/
  1995.  
  1996.             if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  1997.                 (link_ptr->to->lun == ARTMAP_DELb_REC_UNIT)
  1998.                )
  1999.             {
  2000.                has_link_to_delb_unit = TRUE;
  2001.             } /*if*/
  2002.  
  2003.          } /*FOR_ALL_SITES_AND_LINKS*/
  2004.  
  2005.          if (has_link_to_itself && has_link_to_delb_unit) {
  2006.  
  2007.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RSTb))) {
  2008.                 TOPO_MSG_ACT_FUNC (unit_ptr);
  2009.             } /*if*/
  2010.  
  2011.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2012.                  TOPO_MSG_OUT_FUNC (unit_ptr);
  2013.             } /*if*/
  2014.  
  2015.             unit_ptr->lln = ARTMAP_RSTb_LAY;
  2016.             (*no_of_units)++;
  2017.             **topo_ptr = unit_ptr;
  2018.             (*topo_ptr)++;
  2019.             unit_ptr->flags |= UFLAG_REFRESH;
  2020.  
  2021.          } /*if*/
  2022.  
  2023.       } /*if*/
  2024.  
  2025.    } /*FOR_ALL_UNITS*/
  2026.  
  2027.    return (ret_code);
  2028.  
  2029. } /* kram_get_RstUnits_b () */
  2030. /*___________________________________________________________________________*/
  2031.  
  2032.  
  2033. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  2034. static krui_err  kram_get_SpecUnits_b (TopoPtrArray *topo_ptr, int *no_of_units)
  2035. {
  2036.    krui_err                ret_code  = KRERR_NO_ERROR;
  2037.  
  2038.    register struct Unit     *unit_ptr;
  2039.    register struct Site     *site_ptr;
  2040.    register struct Link     *link_ptr;
  2041.  
  2042.    TopoPtrArray             topo_spec_ptr = *topo_ptr;
  2043.  
  2044.    bool                     got_g1b_unit    = FALSE;
  2045.    bool                     got_rib_unit    = FALSE;
  2046.    bool                     got_rcb_unit    = FALSE;
  2047.    bool                     got_rgb_unit    = FALSE;
  2048.    bool                     got_clb_unit    = FALSE;
  2049.    bool                     got_ncb_unit    = FALSE;
  2050.    bool                     got_rhob_unit   = FALSE;
  2051.    bool                     got_g2b_unit    = FALSE;
  2052.  
  2053.    bool                     links_to_rstb_units,
  2054.                             links_to_d3b_unit,
  2055.                             links_to_recb_units,
  2056.                             links_to_cmpb_units,
  2057.                             links_to_inpb_units;
  2058.  
  2059.  
  2060.    *no_of_units = 0;
  2061.  
  2062.    /* looking for special units of ARTb */
  2063.  
  2064.    FOR_ALL_UNITS (unit_ptr) {
  2065.  
  2066.       if ( (!(UNIT_REFRESHED (unit_ptr))) &&
  2067.            (!got_g1b_unit || !got_rib_unit || !got_rcb_unit ||
  2068.             !got_clb_unit || !got_ncb_unit || !got_g2b_unit
  2069.            )
  2070.          )
  2071.       {
  2072.  
  2073.          if (UNIT_HAS_SITES (unit_ptr)) {
  2074.  
  2075.  
  2076.             /* if a unit with sites does have links from inpb units
  2077.                and recb units this can only be the g1b unit
  2078.             */
  2079.             links_to_recb_units = FALSE;
  2080.             links_to_inpb_units = FALSE;
  2081.  
  2082.             FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  2083.  
  2084.                if (link_ptr->to->lln == ARTMAP_RECb_LAY) {
  2085.                   links_to_recb_units = TRUE;
  2086.                } /*if*/
  2087.  
  2088.                if (link_ptr->to->lln == ARTMAP_INPb_LAY) {
  2089.                   links_to_inpb_units = TRUE;
  2090.                } /*if*/
  2091.  
  2092.                if (links_to_inpb_units) {
  2093.                   /* we found the g1b unit */
  2094.                   break;
  2095.                } /*if*/
  2096.  
  2097.             } /*FOR_ALL_SITES_AND_LINKS*/
  2098.  
  2099.             if (links_to_recb_units && links_to_inpb_units) {
  2100.  
  2101.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_G1b))) {
  2102.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  2103.                } /*if*/
  2104.  
  2105.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2106.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  2107.                } /*if*/
  2108.  
  2109.                unit_ptr->lln = ARTMAP_SPECb_LAY;
  2110.                unit_ptr->lun = ARTMAP_G1b_UNIT;
  2111.                (*no_of_units)++;
  2112.                *(topo_spec_ptr + 2) = unit_ptr;
  2113.                got_g1b_unit = TRUE;
  2114.                unit_ptr->flags |= UFLAG_REFRESH;
  2115.                (*topo_ptr)++;
  2116.  
  2117.             } else {
  2118.  
  2119.                if (links_to_inpb_units) {
  2120.  
  2121.                   /* if there are links to the inpb units but none to the
  2122.                      recb units then we found the rib unit
  2123.                   */
  2124.                   if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RIb))) {
  2125.                      TOPO_MSG_ACT_FUNC (unit_ptr);
  2126.                   } /*if*/
  2127.  
  2128.                   if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2129.                       TOPO_MSG_OUT_FUNC (unit_ptr);
  2130.                   } /*if*/
  2131.  
  2132.                   unit_ptr->lln = ARTMAP_SPECb_LAY;
  2133.                   unit_ptr->lun = ARTMAP_RIb_UNIT;
  2134.                   (*no_of_units)++;
  2135.                   *(topo_spec_ptr + 3) = unit_ptr;
  2136.                   got_rib_unit = TRUE;
  2137.                   unit_ptr->flags |= UFLAG_REFRESH;
  2138.                   (*topo_ptr)++;
  2139.  
  2140.                } /*if*/
  2141.  
  2142.             } /*if*/
  2143.  
  2144.          } else {
  2145.  
  2146.             /* unit has direct inputs */
  2147.  
  2148.             links_to_rstb_units = FALSE;
  2149.             links_to_d3b_unit   = FALSE;
  2150.             links_to_cmpb_units = FALSE;
  2151.             links_to_inpb_units = FALSE;
  2152.  
  2153.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  2154.  
  2155.                switch (link_ptr->to->lln) {
  2156.                case ARTMAP_INPb_LAY:
  2157.                   links_to_inpb_units = TRUE;
  2158.                   break;
  2159.                case ARTMAP_CMPb_LAY:
  2160.                   links_to_cmpb_units = TRUE;
  2161.                   break;
  2162.                case ARTMAP_DELb_LAY:
  2163.                   if (link_ptr->to->lun == ARTMAP_D3b_UNIT) {
  2164.                      links_to_d3b_unit = TRUE;
  2165.                   } /*if*/
  2166.                   break;
  2167.                case ARTMAP_RSTb_LAY:
  2168.                   links_to_rstb_units = TRUE;
  2169.                   break;
  2170.                 } /*switch*/
  2171.  
  2172.  
  2173.             } /*FOR_ALL_LINKS*/
  2174.  
  2175.  
  2176.             if (links_to_inpb_units && !got_g2b_unit) {
  2177.  
  2178.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_G2b))) {
  2179.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  2180.                } /*if*/
  2181.  
  2182.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2183.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  2184.                } /*if*/
  2185.  
  2186.                unit_ptr->lln = ARTMAP_SPECb_LAY;
  2187.                unit_ptr->lun = ARTMAP_G2b_UNIT;
  2188.                (*no_of_units)++;
  2189.                *(topo_spec_ptr + 7) = unit_ptr;
  2190.                (*topo_ptr)++;
  2191.                unit_ptr->flags |= UFLAG_REFRESH;
  2192.                got_g2b_unit = TRUE;
  2193.                continue;
  2194.             } /*if*/
  2195.  
  2196.  
  2197.             if (links_to_cmpb_units && !links_to_inpb_units &&
  2198.                 !got_rcb_unit
  2199.                )
  2200.             {
  2201.  
  2202.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RCb))) {
  2203.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  2204.                } /*if*/
  2205.  
  2206.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2207.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  2208.                } /*if*/
  2209.  
  2210.                unit_ptr->lln = ARTMAP_SPECb_LAY;
  2211.                unit_ptr->lun = ARTMAP_RCb_UNIT;
  2212.                (*no_of_units)++;
  2213.                *(topo_spec_ptr + 4) = unit_ptr;
  2214.                (*topo_ptr)++;
  2215.                unit_ptr->flags |= UFLAG_REFRESH;
  2216.                got_rcb_unit = TRUE;
  2217.                continue;
  2218.  
  2219.             } /*if*/
  2220.  
  2221.  
  2222.             if (links_to_d3b_unit && !got_clb_unit) {
  2223.  
  2224.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_CLb))) {
  2225.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  2226.                } /*if*/
  2227.  
  2228.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2229.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  2230.                } /*if*/
  2231.  
  2232.                unit_ptr->lln = ARTMAP_SPECb_LAY;
  2233.                unit_ptr->lun = ARTMAP_CLb_UNIT;
  2234.                (*no_of_units)++;
  2235.                *topo_spec_ptr = unit_ptr;
  2236.                (*topo_ptr)++;
  2237.                unit_ptr->flags |= UFLAG_REFRESH;
  2238.                got_clb_unit = TRUE;
  2239.                continue;
  2240.  
  2241.             } /*if*/
  2242.  
  2243.  
  2244.             if (links_to_rstb_units && !links_to_cmpb_units &&
  2245.                 !got_ncb_unit
  2246.                )
  2247.             {
  2248.                if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_NCb))) {
  2249.                   TOPO_MSG_ACT_FUNC (unit_ptr);
  2250.                } /*if*/
  2251.  
  2252.                if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2253.                   TOPO_MSG_OUT_FUNC (unit_ptr);
  2254.                } /*if*/
  2255.  
  2256.                unit_ptr->lln = ARTMAP_SPECb_LAY;
  2257.                unit_ptr->lun = ARTMAP_NCb_UNIT;
  2258.                (*no_of_units)++;
  2259.                *(topo_spec_ptr + 1) = unit_ptr;
  2260.                (*topo_ptr)++;
  2261.                unit_ptr->flags |= UFLAG_REFRESH;
  2262.                got_ncb_unit = TRUE;
  2263.                continue;
  2264.  
  2265.             } /*if*/
  2266.  
  2267.          } /*if*/
  2268.  
  2269.       } /*if*/
  2270.  
  2271.    } /*FOR_ALL_UNITS*/
  2272.  
  2273.  
  2274.    /* the rgb and the rhob unit remain to be determined */
  2275.  
  2276.    FOR_ALL_UNITS (unit_ptr) {
  2277.  
  2278.       if (!(UNIT_REFRESHED (unit_ptr))) {
  2279.  
  2280.          /* looking for rgb unit */
  2281.  
  2282.          if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  2283.  
  2284.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  2285.  
  2286.                if ((link_ptr->to->lln == ARTMAP_SPECb_LAY) &&
  2287.                    (link_ptr->to->lun == ARTMAP_RIb_UNIT)
  2288.                   )
  2289.                {
  2290.  
  2291.                   if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RGb))) {
  2292.                      TOPO_MSG_ACT_FUNC (unit_ptr);
  2293.                   } /*if*/
  2294.  
  2295.                   if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2296.                      TOPO_MSG_OUT_FUNC (unit_ptr);
  2297.                   } /*if*/
  2298.  
  2299.                    /* this is the rgb unit */
  2300.                    unit_ptr->lln = ARTMAP_SPECb_LAY;
  2301.                    unit_ptr->lun = ARTMAP_RGb_UNIT;
  2302.                    (*no_of_units)++;
  2303.                    *(topo_spec_ptr + 5) = unit_ptr;
  2304.                    got_rgb_unit =TRUE;
  2305.                    (*topo_ptr)++;
  2306.                    unit_ptr->flags |= UFLAG_REFRESH;
  2307.                    break;
  2308.  
  2309.                } /*if*/
  2310.  
  2311.             } /*FOR_ALL_LINKS*/
  2312.  
  2313.          } /*if*/
  2314.  
  2315.       } else {
  2316.  
  2317.          /* looking for rhob unit via ria */
  2318.  
  2319.          if ((unit_ptr->lln == ARTMAP_SPECb_LAY) &&
  2320.              (unit_ptr->lun == ARTMAP_RIb_UNIT)
  2321.             )
  2322.          {
  2323.              FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  2324.  
  2325.                 if (link_ptr->to->lln != ARTMAP_INPb_LAY) {
  2326.  
  2327.                    if (!(CHECK_ACT_FUNC (link_ptr->to, ARTMAP_ACTF_RHOb))) {
  2328.                       TOPO_MSG_ACT_FUNC (link_ptr->to);
  2329.                    } /*if*/
  2330.  
  2331.                    if (!(CHECK_OUT_FUNC (link_ptr->to, ARTMAP_OUTFUNC))) {
  2332.                       TOPO_MSG_OUT_FUNC (link_ptr->to);
  2333.                    } /*if*/
  2334.  
  2335.                    /* the link_ptr->to unit is the rhoa unit */
  2336.  
  2337.                    /* the link_ptr->to unit is the rhob unit */
  2338.  
  2339.                    link_ptr->to->lln = ARTMAP_SPECb_LAY;
  2340.                    link_ptr->to->lun = ARTMAP_RHOb_UNIT;
  2341.                    (*no_of_units)++;
  2342.                    *(topo_spec_ptr + 6) = link_ptr->to;
  2343.                    (*topo_ptr)++;
  2344.                    got_rhob_unit = TRUE;
  2345.                    link_ptr->to->flags |= UFLAG_REFRESH;
  2346.                    break;
  2347.  
  2348.                 } /*if*/
  2349.  
  2350.              } /*FOR_ALL_SITES_AND_LINKS*/
  2351.  
  2352.           } /*if*/
  2353.  
  2354.        } /*if*/
  2355.  
  2356.        if (got_rgb_unit && got_rhob_unit) {
  2357.           break;
  2358.        } /*if*/
  2359.  
  2360.    } /*FOR_ALL_UNITS*/
  2361.  
  2362.    if (!got_clb_unit) {
  2363.       TOPO_MSG_UNIT_MISSING ("ARTb: cl (=clb)");
  2364.    } /*if*/
  2365.  
  2366.    if (!got_ncb_unit) {
  2367.       TOPO_MSG_UNIT_MISSING ("ARTb: nc (=ncb)");
  2368.    } /*if*/
  2369.  
  2370.    if (!got_rib_unit) {
  2371.       TOPO_MSG_UNIT_MISSING ("ARTb: ri (=rib)");
  2372.    } /*if*/
  2373.  
  2374.    if (!got_rcb_unit) {
  2375.       TOPO_MSG_UNIT_MISSING ("ARTb: rc (=rcb)");
  2376.    } /*if*/
  2377.  
  2378.    if (!got_rgb_unit) {
  2379.       TOPO_MSG_UNIT_MISSING ("ARTb: rg (=rgb)");
  2380.    } /*if*/
  2381.  
  2382.    if (!got_g1b_unit) {
  2383.       TOPO_MSG_UNIT_MISSING ("ARTb: g1 (=g1b)");
  2384.    } /*if*/
  2385.  
  2386.    if (!got_rhob_unit) {
  2387.       TOPO_MSG_UNIT_MISSING ("ARTb: rho (=rhob)");
  2388.    } /*if*/
  2389.  
  2390.    if (!got_g2b_unit) {
  2391.       TOPO_MSG_UNIT_MISSING ("ARTb: g2 (=g2b)");
  2392.    } /*if*/
  2393.  
  2394.  
  2395.    return (ret_code);
  2396.  
  2397. } /* kram_get_SpecUnits_b () */
  2398. /*___________________________________________________________________________*/
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405. /*************** functions to determine units of map field of ARTMAP net
  2406. ***************/
  2407.  
  2408.  
  2409. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  2410. static krui_err  kram_get_MapUnits (TopoPtrArray *topo_ptr, int *no_of_units)
  2411. {
  2412.    krui_err                ret_code  = KRERR_NO_ERROR;
  2413.  
  2414.    register struct Unit    *unit_ptr;
  2415.    register struct Link    *link_ptr;
  2416.  
  2417.    bool                    has_link_to_dela_unit,
  2418.                            has_link_to_delb_unit;
  2419.  
  2420.    *no_of_units = 0;
  2421.  
  2422.    /* looking for map units. These units have got incoming
  2423.       links from the dela units and the delb units. They have
  2424.       no sites.
  2425.    */
  2426.  
  2427.    FOR_ALL_UNITS (unit_ptr) {
  2428.  
  2429.       if (!(UNIT_REFRESHED (unit_ptr)) && (UNIT_HAS_DIRECT_INPUTS (unit_ptr))) {
  2430.  
  2431.          has_link_to_dela_unit = FALSE;
  2432.          has_link_to_delb_unit = FALSE;
  2433.  
  2434.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  2435.  
  2436.             if (link_ptr->to->lln == ARTMAP_DELa_LAY) {
  2437.                has_link_to_dela_unit = TRUE;
  2438.                continue;
  2439.             } /*if*/
  2440.  
  2441.             if (link_ptr->to->lln == ARTMAP_DELb_LAY) {
  2442.                has_link_to_delb_unit = TRUE;
  2443.                continue;
  2444.             } /*if*/
  2445.  
  2446.             if (has_link_to_dela_unit && has_link_to_delb_unit) {
  2447.                break;
  2448.             } /*if*/
  2449.  
  2450.          } /*FOR_ALL_LINKS*/
  2451.  
  2452.          if (has_link_to_dela_unit && has_link_to_delb_unit) {
  2453.  
  2454.             if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_MAP))) {
  2455.                TOPO_MSG_ACT_FUNC (unit_ptr);
  2456.             } /*if*/
  2457.  
  2458.             if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2459.                TOPO_MSG_OUT_FUNC (unit_ptr);
  2460.             } /*if*/
  2461.  
  2462.             unit_ptr->lln = ARTMAP_MAP_LAY;
  2463.             (*no_of_units)++;
  2464.             **topo_ptr = unit_ptr;
  2465.             (*topo_ptr)++;
  2466.             unit_ptr->flags |= UFLAG_REFRESH;
  2467.  
  2468.          } /*if*/
  2469.  
  2470.       } /*if*/
  2471.  
  2472.    } /*FOR_ALL_UNITS*/
  2473.  
  2474.    return (ret_code);
  2475.  
  2476. } /* kram_get_MapUnits () */
  2477. /*___________________________________________________________________________*/
  2478.  
  2479.  
  2480.  
  2481. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  2482. static krui_err   kram_get_SpecUnits (TopoPtrArray *topo_ptr, int *no_of_units)
  2483. {
  2484.     krui_err                  ret_code  = KRERR_NO_ERROR;
  2485.  
  2486.     register struct Unit       *unit_ptr;
  2487.     register struct Site       *site_ptr;
  2488.     register struct Link       *link_ptr;
  2489.  
  2490.     TopoPtrArray               topo_spec_ptr = *topo_ptr;
  2491.  
  2492.     bool                       has_links_to_reca_units,
  2493.                                has_links_to_inpa_units,
  2494.                                has_link_to_cla_unit,
  2495.                                has_link_to_nca_unit,
  2496.                                has_link_to_itself,
  2497.                                has_links_to_map_units,
  2498.                                has_link_to_rhoa_unit,
  2499.                                has_link_to_delb_unit,
  2500.                                has_link_to_rga_unit;
  2501.  
  2502.     bool                       got_d1_unit    = FALSE;
  2503.     bool                       got_cl_unit    = FALSE;
  2504.     bool                       got_nc_unit    = FALSE;
  2505.     bool                       got_G_unit     = FALSE;
  2506.     bool                       got_rb_unit    = FALSE;
  2507.     bool                       got_rm_unit    = FALSE;
  2508.     bool                       got_rg_unit    = FALSE;
  2509.     bool                       got_rho_unit   = FALSE;
  2510.     bool                       got_qu_unit    = FALSE;
  2511.     bool                       got_drho_unit  = FALSE;
  2512.  
  2513.  
  2514.     FOR_ALL_UNITS (unit_ptr) {
  2515.  
  2516.        if (!(UNIT_REFRESHED (unit_ptr))) {
  2517.  
  2518.           if (UNIT_HAS_SITES (unit_ptr)) {
  2519.  
  2520.              /* G, rb or qu unit */
  2521.  
  2522.              has_links_to_reca_units = FALSE;
  2523.              has_links_to_inpa_units = FALSE;
  2524.  
  2525.              FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  2526.  
  2527.                 switch (link_ptr->to->lln) {
  2528.                 case ARTMAP_RECa_LAY:
  2529.                    has_links_to_reca_units = TRUE;
  2530.                    break;
  2531.                 case ARTMAP_INPa_LAY:
  2532.                    has_links_to_inpa_units = TRUE;
  2533.                    break;
  2534.                 } /*if*/
  2535.  
  2536.              } /*FOR_ALL_SITES_AND_LINKS*/
  2537.  
  2538.              if (has_links_to_reca_units && !got_G_unit) {
  2539.  
  2540.                 if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_G))) {
  2541.                    TOPO_MSG_ACT_FUNC (unit_ptr);
  2542.                 } /*if*/
  2543.  
  2544.                 if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2545.                    TOPO_MSG_OUT_FUNC (unit_ptr);
  2546.                 } /*if*/
  2547.  
  2548.                 /* This is the G unit */
  2549.                 unit_ptr->lln = ARTMAP_SPEC_LAY;
  2550.                 unit_ptr->lun = ARTMAP_G_UNIT;
  2551.                 *(topo_spec_ptr + 3) = unit_ptr;
  2552.                 (*topo_ptr)++;
  2553.                 (*no_of_units)++;
  2554.                 unit_ptr->flags |= UFLAG_REFRESH;
  2555.                 got_G_unit = TRUE;
  2556.                 continue;
  2557.  
  2558.               } /*if*/
  2559.  
  2560.  
  2561.              if (has_links_to_inpa_units && !got_qu_unit) {
  2562.  
  2563.                 if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_QU))) {
  2564.                    TOPO_MSG_ACT_FUNC (unit_ptr);
  2565.                 } /*if*/
  2566.  
  2567.                 if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2568.                    TOPO_MSG_OUT_FUNC (unit_ptr);
  2569.                 } /*if*/
  2570.  
  2571.                 /* This is the qu unit */
  2572.                 unit_ptr->lln = ARTMAP_SPEC_LAY;
  2573.                 unit_ptr->lun = ARTMAP_QU_UNIT;
  2574.                 *(topo_spec_ptr + 8) = unit_ptr;
  2575.                 (*topo_ptr)++;
  2576.                 (*no_of_units)++;
  2577.                 unit_ptr->flags |= UFLAG_REFRESH;
  2578.                 got_qu_unit = TRUE;
  2579.                 continue;
  2580.  
  2581.               } /*if*/
  2582.  
  2583.               if (!got_rb_unit) {
  2584.  
  2585.                 if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RB))) {
  2586.                    TOPO_MSG_ACT_FUNC (unit_ptr);
  2587.                 } /*if*/
  2588.  
  2589.                 if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2590.                    TOPO_MSG_OUT_FUNC (unit_ptr);
  2591.                 } /*if*/
  2592.  
  2593.                 /* This is the rb unit */
  2594.                 unit_ptr->lln = ARTMAP_SPEC_LAY;
  2595.                 unit_ptr->lun = ARTMAP_RB_UNIT;
  2596.                 *(topo_spec_ptr + 4) = unit_ptr;
  2597.                 (*topo_ptr)++;
  2598.                 (*no_of_units)++;
  2599.                 unit_ptr->flags |= UFLAG_REFRESH;
  2600.                 got_rb_unit = TRUE;
  2601.  
  2602.               } /*if*/
  2603.  
  2604.           }  else {
  2605.  
  2606.               /* unit has no sites, so this is the cl, nc, rho, rm,
  2607.                  drho or rg unit
  2608.               */
  2609.  
  2610.               has_link_to_cla_unit   = FALSE;
  2611.               has_link_to_nca_unit   = FALSE;
  2612.               has_link_to_itself     = FALSE;
  2613.               has_links_to_map_units = FALSE;
  2614.               has_link_to_rhoa_unit  = FALSE;
  2615.               has_link_to_delb_unit  = FALSE;
  2616.               has_link_to_rga_unit   = FALSE;
  2617.  
  2618.  
  2619.               FOR_ALL_LINKS (unit_ptr, link_ptr) {
  2620.  
  2621.                  switch (link_ptr->to->lln) {
  2622.                  case ARTMAP_SPECa_LAY :
  2623.  
  2624.                     switch (link_ptr->to->lun) {
  2625.                     case ARTMAP_CLa_UNIT:
  2626.                        has_link_to_cla_unit = TRUE;
  2627.                        break;
  2628.                     case ARTMAP_NCa_UNIT:
  2629.                        has_link_to_nca_unit = TRUE;
  2630.                        break;
  2631.                     case ARTMAP_RHOa_UNIT:
  2632.                        has_link_to_rhoa_unit = TRUE;
  2633.                        break;
  2634.                     case ARTMAP_RGa_UNIT:
  2635.                        has_link_to_rga_unit = TRUE;
  2636.                        break;
  2637.                     } /*switch*/
  2638.  
  2639.                     break;
  2640.  
  2641.                  case ARTMAP_MAP_LAY:
  2642.                     has_links_to_map_units = TRUE;
  2643.                     break;
  2644.  
  2645.                  case ARTMAP_DELb_LAY:
  2646.                     has_link_to_delb_unit = TRUE;
  2647.                     break;
  2648.  
  2649.                  default:
  2650.                     if (link_ptr->to == unit_ptr) {
  2651.                        has_link_to_itself = TRUE;
  2652.                     } /*if*/
  2653.  
  2654.                  } /*switch*/
  2655.  
  2656.               } /*FOR_ALL_LINKS*/
  2657.  
  2658.               if (has_link_to_cla_unit && !got_cl_unit) {
  2659.  
  2660.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_CL))) {
  2661.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2662.                  } /*if*/
  2663.  
  2664.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2665.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2666.                  } /*if*/
  2667.  
  2668.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2669.                  unit_ptr->lun = ARTMAP_CL_UNIT;
  2670.                  ArtMap_cl_unit = unit_ptr;
  2671.                  *(topo_spec_ptr + 1) = unit_ptr;
  2672.                  (*topo_ptr)++;
  2673.                  (*no_of_units)++;
  2674.                  unit_ptr->flags |= UFLAG_REFRESH;
  2675.                  got_cl_unit = TRUE;
  2676.                  continue;
  2677.  
  2678.               } /*if*/
  2679.  
  2680.               if (has_link_to_nca_unit && !got_nc_unit) {
  2681.  
  2682.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_NC))) {
  2683.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2684.                  } /*if*/
  2685.  
  2686.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2687.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2688.                  } /*if*/
  2689.  
  2690.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2691.                  unit_ptr->lun = ARTMAP_NC_UNIT;
  2692.                  ArtMap_nc_unit = unit_ptr;
  2693.                  *(topo_spec_ptr + 2) = unit_ptr;
  2694.                  (*topo_ptr)++;
  2695.                  (*no_of_units)++;
  2696.                  unit_ptr->flags |= UFLAG_REFRESH;
  2697.                  got_nc_unit = TRUE;
  2698.                  continue;
  2699.  
  2700.               } /*if*/
  2701.  
  2702.               if (has_link_to_itself && !got_rho_unit) {
  2703.  
  2704.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RHO))) {
  2705.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2706.                  } /*if*/
  2707.  
  2708.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2709.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2710.                  } /*if*/
  2711.  
  2712.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2713.                  unit_ptr->lun = ARTMAP_RHO_UNIT;
  2714.                  *(topo_spec_ptr + 7) = unit_ptr;
  2715.                  (*topo_ptr)++;
  2716.                  (*no_of_units)++;
  2717.                  unit_ptr->flags |= UFLAG_REFRESH;
  2718.                  got_rho_unit = TRUE;
  2719.                  continue;
  2720.  
  2721.               } /*if*/
  2722.  
  2723.               if (has_links_to_map_units && !got_rm_unit) {
  2724.  
  2725.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RM))) {
  2726.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2727.                  } /*if*/
  2728.  
  2729.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2730.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2731.                  } /*if*/
  2732.  
  2733.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2734.                  unit_ptr->lun = ARTMAP_RM_UNIT;
  2735.                  *(topo_spec_ptr + 5) = unit_ptr;
  2736.                  (*topo_ptr)++;
  2737.                  (*no_of_units)++;
  2738.                  unit_ptr->flags |= UFLAG_REFRESH;
  2739.                  got_rm_unit = TRUE;
  2740.                  continue;
  2741.  
  2742.               } /*if*/
  2743.  
  2744.               if (has_link_to_rga_unit && has_link_to_rhoa_unit &&
  2745.                   ! got_drho_unit
  2746.                  )
  2747.               {
  2748.  
  2749.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_DRHO))) {
  2750.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2751.                  } /*if*/
  2752.  
  2753.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2754.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2755.                  } /*if*/
  2756.  
  2757.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2758.                  unit_ptr->lun = ARTMAP_DRHO_UNIT;
  2759.                  *(topo_spec_ptr + 9) = unit_ptr;
  2760.                  (*topo_ptr)++;
  2761.                  (*no_of_units)++;
  2762.                  unit_ptr->flags |= UFLAG_REFRESH;
  2763.                  got_drho_unit = TRUE;
  2764.                  continue;
  2765.  
  2766.               } /*if*/
  2767.  
  2768.               if (has_link_to_delb_unit && !got_d1_unit) {
  2769.  
  2770.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_D1))) {
  2771.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2772.                  } /*if*/
  2773.  
  2774.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2775.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2776.                  } /*if*/
  2777.  
  2778.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2779.                  unit_ptr->lun = ARTMAP_D1_UNIT;
  2780.                  *topo_spec_ptr = unit_ptr;
  2781.                  (*topo_ptr)++;
  2782.                  (*no_of_units)++;
  2783.                  unit_ptr->flags |= UFLAG_REFRESH;
  2784.                  got_d1_unit = TRUE;
  2785.                  continue;
  2786.  
  2787.               } /*if*/
  2788.  
  2789.               if (!got_rg_unit) {
  2790.  
  2791.                  if (!(CHECK_ACT_FUNC (unit_ptr, ARTMAP_ACTF_RG))) {
  2792.                     TOPO_MSG_ACT_FUNC (unit_ptr);
  2793.                  } /*if*/
  2794.  
  2795.                  if (!(CHECK_OUT_FUNC (unit_ptr, ARTMAP_OUTFUNC))) {
  2796.                     TOPO_MSG_OUT_FUNC (unit_ptr);
  2797.                  } /*if*/
  2798.  
  2799.                  unit_ptr->lln = ARTMAP_SPEC_LAY;
  2800.                  unit_ptr->lun = ARTMAP_RG_UNIT;
  2801.                  *(topo_spec_ptr + 6) = unit_ptr;
  2802.                  (*topo_ptr)++;
  2803.                  (*no_of_units)++;
  2804.                  unit_ptr->flags |= UFLAG_REFRESH;
  2805.                  got_rg_unit = TRUE;
  2806.  
  2807.               } /*if*/
  2808.  
  2809.           } /*if (UNIT_HAS_SITES)*/
  2810.  
  2811.        } /* if (!UNIT_REFRESHED)*/
  2812.  
  2813.     } /*FOR_ALL_UNITS*/
  2814.  
  2815.    if (!got_cl_unit) {
  2816.       TOPO_MSG_UNIT_MISSING ("MAP: cl");
  2817.    } /*if*/
  2818.  
  2819.    if (!got_nc_unit) {
  2820.       TOPO_MSG_UNIT_MISSING ("MAP: nc");
  2821.    } /*if*/
  2822.  
  2823.    if (!got_rb_unit) {
  2824.       TOPO_MSG_UNIT_MISSING ("MAP: rb");
  2825.    } /*if*/
  2826.  
  2827.    if (!got_rm_unit) {
  2828.       TOPO_MSG_UNIT_MISSING ("MAP: rm");
  2829.    } /*if*/
  2830.  
  2831.    if (!got_rg_unit) {
  2832.       TOPO_MSG_UNIT_MISSING ("MAP: rg");
  2833.    } /*if*/
  2834.  
  2835.    if (!got_G_unit) {
  2836.       TOPO_MSG_UNIT_MISSING ("MAP: G");
  2837.    } /*if*/
  2838.  
  2839.    if (!got_d1_unit) {
  2840.       TOPO_MSG_UNIT_MISSING ("MAP: d1");
  2841.    } /*if*/
  2842.  
  2843.    if (!got_rho_unit) {
  2844.       TOPO_MSG_UNIT_MISSING ("MAP: rho");
  2845.    } /*if*/
  2846.  
  2847.    if (!got_qu_unit) {
  2848.       TOPO_MSG_UNIT_MISSING ("MAP: qu");
  2849.    } /*if*/
  2850.  
  2851.    if (!got_drho_unit) {
  2852.       TOPO_MSG_UNIT_MISSING ("MAP: drho");
  2853.    } /*if*/
  2854.  
  2855.     return (ret_code);
  2856.  
  2857. } /* kram_get_SpecUnits */
  2858. /*___________________________________________________________________________*/
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864. /**************** funciton for checking topo ptr array of ARTMAP net
  2865. ****************/
  2866.  
  2867.  
  2868.  
  2869. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  2870. static krui_err   kram_TopoPtrArray (void)
  2871. {
  2872.    TopoPtrArray    topo_inpa_cmpa_sep,
  2873.                    topo_cmpa_reca_sep,
  2874.                    topo_reca_dela_sep,
  2875.                    topo_dela_rsta_sep,
  2876.                    topo_rsta_speca_sep,
  2877.                    topo_speca_inpb_sep,
  2878.                    topo_inpb_cmpb_sep,
  2879.                    topo_cmpb_recb_sep,
  2880.                    topo_recb_delb_sep,
  2881.                    topo_delb_rstb_sep,
  2882.                    topo_rstb_specb_sep,
  2883.                    topo_specb_map_sep,
  2884.                    topo_map_spec_sep,
  2885.                    topo_ptr_array_end;
  2886.  
  2887.    int             ret_code = KRERR_NO_ERROR;
  2888.  
  2889.  
  2890.    topo_inpa_cmpa_sep = topo_ptr_array + ArtMap_NoOfInpUnits_a + 1;
  2891.    topo_cmpa_reca_sep = topo_inpa_cmpa_sep + ArtMap_NoOfInpUnits_a + 1;
  2892.    topo_reca_dela_sep = topo_cmpa_reca_sep + ArtMap_NoOfRecUnits_a + 1;
  2893.    topo_dela_rsta_sep = topo_reca_dela_sep + ArtMap_NoOfRecUnits_a + 4;
  2894.    topo_rsta_speca_sep = topo_dela_rsta_sep + ArtMap_NoOfRecUnits_a + 1;
  2895.    topo_speca_inpb_sep = topo_rsta_speca_sep + ARTMAP_NO_OF_SPECa_UNITS + 1;
  2896.    topo_inpb_cmpb_sep = topo_speca_inpb_sep + ArtMap_NoOfInpUnits_b + 1;
  2897.    topo_cmpb_recb_sep = topo_inpb_cmpb_sep + ArtMap_NoOfInpUnits_b + 1;
  2898.    topo_recb_delb_sep = topo_cmpb_recb_sep + ArtMap_NoOfRecUnits_b + 1;
  2899.    topo_delb_rstb_sep = topo_recb_delb_sep + ArtMap_NoOfRecUnits_b + 4;
  2900.    topo_rstb_specb_sep = topo_delb_rstb_sep + ArtMap_NoOfRecUnits_b + 1;
  2901.    topo_specb_map_sep = topo_rstb_specb_sep + ARTMAP_NO_OF_SPECb_UNITS + 1;
  2902.    topo_map_spec_sep = topo_specb_map_sep + ArtMap_NoOfRecUnits_b + 1;
  2903.  
  2904.    topo_ptr_array_end = topo_map_spec_sep + ARTMAP_NO_OF_SPEC_UNITS + 1;
  2905.  
  2906.    if ((*topo_ptr_array != NULL)      ||
  2907.        (*topo_inpa_cmpa_sep != NULL)  ||
  2908.        (*topo_cmpa_reca_sep != NULL)  ||
  2909.        (*topo_reca_dela_sep != NULL)  ||
  2910.        (*topo_dela_rsta_sep != NULL)  ||
  2911.        (*topo_rsta_speca_sep != NULL) ||
  2912.        (*topo_speca_inpb_sep != NULL) ||
  2913.        (*topo_inpb_cmpb_sep != NULL)  ||
  2914.        (*topo_cmpb_recb_sep != NULL)  ||
  2915.        (*topo_recb_delb_sep != NULL)  ||
  2916.        (*topo_delb_rstb_sep != NULL)  ||
  2917.        (*topo_rstb_specb_sep != NULL) ||
  2918.        (*topo_specb_map_sep != NULL)  ||
  2919.        (*topo_map_spec_sep != NULL)   ||
  2920.        (*topo_ptr_array_end != NULL)  ||
  2921.        (*(topo_ptr_array_end+1) != NULL)
  2922.       )
  2923.    {
  2924.       ARTMAP_RETURN_NET_ERROR (ret_code);
  2925.    } /*if*/
  2926.  
  2927.  
  2928.    return (ret_code);
  2929.  
  2930.  
  2931. } /* kram_TopoPtrArray */
  2932. /*___________________________________________________________________________*/
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939. /****************** function for checking sites of ARTMAP network
  2940. ******************/
  2941.  
  2942.  
  2943. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  2944. static krui_err   kram_Sites (void)
  2945. {
  2946.    register struct Unit   *unit_ptr;
  2947.    register struct Site   *site_ptr;
  2948.  
  2949.    TopoPtrArray           topo_rsta_ptr,
  2950.                           topo_g1a_ptr,
  2951.                           topo_ria_ptr,
  2952.                           topo_rstb_ptr,
  2953.                           topo_g1b_ptr,
  2954.                           topo_rib_ptr,
  2955.                           topo_G_ptr,
  2956.                           topo_rb_ptr,
  2957.                           topo_qu_ptr;
  2958.  
  2959.    bool                   got_site1,
  2960.                           got_site2;
  2961.  
  2962.    krui_err               ret_code = KRERR_NO_ERROR;
  2963.  
  2964.  
  2965.  
  2966.    topo_rsta_ptr = topo_ptr_array + 2*ArtMap_NoOfInpUnits_a +
  2967.                    2*ArtMap_NoOfRecUnits_a + 8;
  2968.    topo_g1a_ptr  = topo_rsta_ptr + ArtMap_NoOfRecUnits_a + 3;
  2969.    topo_ria_ptr  = topo_g1a_ptr + 1;
  2970.    topo_rstb_ptr = topo_ria_ptr + 5 + 2*ArtMap_NoOfInpUnits_b +
  2971.                    2*ArtMap_NoOfRecUnits_b + 8;
  2972.    topo_g1b_ptr  = topo_rstb_ptr + ArtMap_NoOfRecUnits_b + 3;
  2973.    topo_rib_ptr  = topo_g1b_ptr + 1;
  2974.    topo_G_ptr    = topo_rib_ptr + 5 + ArtMap_NoOfRecUnits_b + 5;
  2975.    topo_rb_ptr   = topo_G_ptr + 1;
  2976.    topo_qu_ptr   = topo_rb_ptr + 4;
  2977.  
  2978.    /* check sites of local reset units of ARTa
  2979.    */
  2980.    while ((unit_ptr = *topo_rsta_ptr++) != NULL) {
  2981.  
  2982.       got_site1 = FALSE;
  2983.       got_site2 = FALSE;
  2984.  
  2985.       if (UNIT_HAS_SITES (unit_ptr)) {
  2986.  
  2987.          FOR_ALL_SITES (unit_ptr, site_ptr) {
  2988.  
  2989.             if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RSTa_SELF)) && (!got_site1)) {
  2990.                got_site1 = TRUE;
  2991.                continue;
  2992.             } /*if*/
  2993.  
  2994.             if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RSTa_SIGNAL)) && (!got_site2)) {
  2995.                got_site2 = TRUE;
  2996.                continue;
  2997.             } /*if*/
  2998.  
  2999.             TOPO_MSG_SITE_FUNC (unit_ptr);
  3000.  
  3001.          } /*FOR_ALL_SITES*/
  3002.  
  3003.  
  3004.          if (!got_site1 || !got_site2) {
  3005.             TOPO_MSG_SITE_MISSING  (unit_ptr);
  3006.          } /*if*/
  3007.  
  3008.  
  3009.       } else {
  3010.  
  3011.          TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  3012.  
  3013.       } /*if*/
  3014.  
  3015.    } /*while*/
  3016.  
  3017.  
  3018.  
  3019.    /* Check sites of unit Gain 1 of ARTa */
  3020.  
  3021.    if (UNIT_HAS_DIRECT_INPUTS (*topo_g1a_ptr)) {
  3022.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_g1a_ptr);
  3023.    } /*if*/
  3024.  
  3025.    got_site1 = FALSE;
  3026.    got_site2 = FALSE;
  3027.  
  3028.    FOR_ALL_SITES (*topo_g1a_ptr, site_ptr) {
  3029.  
  3030.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_INPa_G1a)) && (!got_site1)) {
  3031.          got_site1 = TRUE;
  3032.          continue;
  3033.       } /*if*/
  3034.  
  3035.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RECa_G1a)) && (!got_site2)) {
  3036.          got_site2 = TRUE;
  3037.          continue;
  3038.       } /*if*/
  3039.  
  3040.       TOPO_MSG_SITE_FUNC (*topo_g1a_ptr);
  3041.  
  3042.    } /*FOR_ALL_SITES*/
  3043.  
  3044.    if (!got_site1 || !got_site2) {
  3045.       TOPO_MSG_SITE_MISSING  (*topo_g1a_ptr);
  3046.    } /*if*/
  3047.  
  3048.  
  3049.    /* Check sites of unit RIa */
  3050.  
  3051.    if (UNIT_HAS_DIRECT_INPUTS (*topo_ria_ptr)) {
  3052.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_ria_ptr);
  3053.    } /*if*/
  3054.  
  3055.    got_site1 = FALSE;
  3056.    got_site2 = FALSE;
  3057.  
  3058.    FOR_ALL_SITES (*topo_ria_ptr, site_ptr) {
  3059.  
  3060.       if (CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RIa)) {
  3061.          if (!got_site1) {
  3062.             got_site1 = TRUE;
  3063.          } else {
  3064.             if (!got_site2) {
  3065.                got_site2 = TRUE;
  3066.             } else {
  3067.                TOPO_MSG_SITE_FUNC (*topo_ria_ptr);
  3068.             } /*if*/
  3069.          } /*if*/
  3070.       } /*if*/
  3071.  
  3072.    } /*FOR_ALL_SITES*/
  3073.  
  3074.    if (!got_site1 || !got_site2) {
  3075.       TOPO_MSG_SITE_MISSING (*topo_ria_ptr);
  3076.    } /*if*/
  3077.  
  3078.  
  3079.  
  3080.    /* check sites of local reset units of ARTb
  3081.    */
  3082.    while ((unit_ptr = *topo_rstb_ptr++) != NULL) {
  3083.  
  3084.       got_site1 = FALSE;
  3085.       got_site2 = FALSE;
  3086.  
  3087.       if (UNIT_HAS_SITES (unit_ptr)) {
  3088.  
  3089.          FOR_ALL_SITES (unit_ptr, site_ptr) {
  3090.  
  3091.             if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RSTb_SELF)) && (!got_site1)) {
  3092.                got_site1 = TRUE;
  3093.                continue;
  3094.             } /*if*/
  3095.  
  3096.             if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RSTb_SIGNAL)) && (!got_site2)) {
  3097.                got_site2 = TRUE;
  3098.                continue;
  3099.             } /*if*/
  3100.  
  3101.             TOPO_MSG_SITE_FUNC (unit_ptr);
  3102.  
  3103.          } /*FOR_ALL_SITES*/
  3104.  
  3105.  
  3106.          if (!got_site1 || !got_site2) {
  3107.             TOPO_MSG_SITE_MISSING (unit_ptr);
  3108.          } /*if*/
  3109.  
  3110.  
  3111.       } else {
  3112.  
  3113.          TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  3114.  
  3115.       } /*if*/
  3116.  
  3117.    } /*while*/
  3118.  
  3119.  
  3120.  
  3121.    /* Check sites of unit Gain 1 of ARTb */
  3122.  
  3123.    if (UNIT_HAS_DIRECT_INPUTS (*topo_g1b_ptr)) {
  3124.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_g1b_ptr);
  3125.    } /*if*/
  3126.  
  3127.    got_site1 = FALSE;
  3128.    got_site2 = FALSE;
  3129.  
  3130.    FOR_ALL_SITES (*topo_g1b_ptr, site_ptr) {
  3131.  
  3132.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_INPb_G1b)) && (!got_site1)) {
  3133.          got_site1 = TRUE;
  3134.          continue;
  3135.       } /*if*/
  3136.  
  3137.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RECb_G1b)) && (!got_site2)) {
  3138.          got_site2 = TRUE;
  3139.          continue;
  3140.       } /*if*/
  3141.  
  3142.       TOPO_MSG_SITE_FUNC (*topo_g1b_ptr);
  3143.  
  3144.    } /*FOR_ALL_SITES*/
  3145.  
  3146.    if (!got_site1 || !got_site2) {
  3147.       TOPO_MSG_SITE_MISSING (*topo_g1b_ptr);
  3148.    } /*if*/
  3149.  
  3150.  
  3151.    /* Check sites of unit RIb */
  3152.  
  3153.    if (UNIT_HAS_DIRECT_INPUTS (*topo_rib_ptr)) {
  3154.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_rib_ptr);
  3155.    } /*if*/
  3156.  
  3157.    got_site1 = FALSE;
  3158.    got_site2 = FALSE;
  3159.  
  3160.    FOR_ALL_SITES (*topo_rib_ptr, site_ptr) {
  3161.  
  3162.       if (CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RIb)) {
  3163.          if (!got_site1) {
  3164.             got_site1 = TRUE;
  3165.          } else {
  3166.             if (!got_site2) {
  3167.                got_site2 = TRUE;
  3168.             } else {
  3169.                TOPO_MSG_SITE_FUNC (*topo_rib_ptr);
  3170.             } /*if*/
  3171.          } /*if*/
  3172.       } /*if*/
  3173.  
  3174.    } /*FOR_ALL_SITES*/
  3175.  
  3176.    if (!got_site1 || !got_site2) {
  3177.       TOPO_MSG_SITE_MISSING (*topo_rib_ptr);
  3178.    } /*if*/
  3179.  
  3180.  
  3181.  
  3182.  
  3183.    /* Check sites of unit G */
  3184.  
  3185.    if (UNIT_HAS_DIRECT_INPUTS (*topo_G_ptr)) {
  3186.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_G_ptr);
  3187.    } /*if*/
  3188.  
  3189.    got_site1 = FALSE;
  3190.    got_site2 = FALSE;
  3191.  
  3192.    FOR_ALL_SITES (*topo_G_ptr, site_ptr) {
  3193.  
  3194.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_ARTa_G)) && (!got_site1)) {
  3195.          got_site1 = TRUE;
  3196.          continue;
  3197.       } /*if*/
  3198.  
  3199.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_ARTb_G)) && (!got_site2)) {
  3200.          got_site2 = TRUE;
  3201.          continue;
  3202.       } /*if*/
  3203.  
  3204.       TOPO_MSG_SITE_FUNC (*topo_G_ptr);
  3205.  
  3206.    } /*FOR_ALL_SITES*/
  3207.  
  3208.    if (!got_site1 || !got_site2) {
  3209.       TOPO_MSG_SITE_MISSING (*topo_G_ptr);
  3210.    } /*if*/
  3211.  
  3212.  
  3213.  
  3214.  
  3215.    /* Check sites of unit rb */
  3216.  
  3217.    if (UNIT_HAS_DIRECT_INPUTS (*topo_rb_ptr)) {
  3218.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_rb_ptr);
  3219.    } /*if*/
  3220.  
  3221.    got_site1 = FALSE;
  3222.    got_site2 = FALSE;
  3223.  
  3224.    FOR_ALL_SITES (*topo_rb_ptr, site_ptr) {
  3225.  
  3226.       if (CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_RB)) {
  3227.          if (!got_site1) {
  3228.             got_site1 = TRUE;
  3229.          } else {
  3230.             if (!got_site2) {
  3231.                got_site2 = TRUE;
  3232.             } else {
  3233.                TOPO_MSG_SITE_FUNC (*topo_rb_ptr);
  3234.             } /*if*/
  3235.          } /*if*/
  3236.       } /*if*/
  3237.  
  3238.    } /*FOR_ALL_SITES*/
  3239.  
  3240.    if (!got_site1 || !got_site2) {
  3241.       TOPO_MSG_SITE_MISSING (*topo_rb_ptr);
  3242.    } /*if*/
  3243.  
  3244.  
  3245.  
  3246.  
  3247.    /* Check sites of unit qu */
  3248.  
  3249.    if (UNIT_HAS_DIRECT_INPUTS (*topo_qu_ptr)) {
  3250.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (*topo_qu_ptr);
  3251.    } /*if*/
  3252.  
  3253.    got_site1 = FALSE;
  3254.    got_site2 = FALSE;
  3255.  
  3256.    FOR_ALL_SITES (*topo_qu_ptr, site_ptr) {
  3257.  
  3258.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_CMPa_QU)) && (!got_site1)) {
  3259.          got_site1 = TRUE;
  3260.          continue;
  3261.       } /*if*/
  3262.  
  3263.       if ((CHECK_SITE_FUNC (site_ptr, ARTMAP_SITEF_INPa_QU)) && (!got_site2)) {
  3264.          got_site2 = TRUE;
  3265.          continue;
  3266.       } /*if*/
  3267.  
  3268.       TOPO_MSG_SITE_FUNC (*topo_qu_ptr);
  3269.  
  3270.    } /*FOR_ALL_SITES*/
  3271.  
  3272.    if (!got_site1 || !got_site2) {
  3273.       TOPO_MSG_SITE_MISSING (*topo_qu_ptr);
  3274.    } /*if*/
  3275.  
  3276.  
  3277.  
  3278.  
  3279.    return (ret_code);
  3280.  
  3281. } /* kram_Sites () */
  3282. /*___________________________________________________________________________*/
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292. /*####################  functions for checking links of ARTa
  3293. ####################*/
  3294.  
  3295.  
  3296.  
  3297.  
  3298. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  3299. static krui_err  kram_LinksToInpUnits_a (TopoPtrArray *topo_ptr)
  3300. {
  3301.    register struct Unit   *unit_ptr;
  3302.  
  3303.    krui_err               ret_code = KRERR_NO_ERROR;
  3304.  
  3305.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  3306.  
  3307.       if (UNIT_HAS_INPUTS (unit_ptr)) {
  3308.          topo_msg.error_code = KRERR_I_UNITS_CONNECT;
  3309.          topo_msg.dest_error_unit = unit_ptr-unit_array;
  3310.          topo_msg.src_error_unit = 0;
  3311.          ret_code = topo_msg.error_code;
  3312.       } /*if*/
  3313.  
  3314.    } /*while*/
  3315.  
  3316.    return (ret_code);
  3317.  
  3318. } /* kram_LinksToInpUnits_a () */
  3319. /*___________________________________________________________________________*/
  3320.  
  3321.  
  3322.  
  3323. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  3324. static krui_err   kram_LinksToCmpUnits_a (TopoPtrArray *topo_ptr)
  3325. {
  3326.    register struct Unit     *unit_ptr;
  3327.    register struct Link     *link_ptr;
  3328.  
  3329.    int                      count_inp,
  3330.                             count_spec,
  3331.                             count_del;
  3332.  
  3333.  
  3334.    krui_err                 ret_code = KRERR_NO_ERROR;
  3335.  
  3336.  
  3337.    /* - each comparison unit has a link to exactly one input unit which itself
  3338.         is connected to only this comparison unit and no other.
  3339.       - each comparison unit is linked to the gain 1 unit
  3340.       - each comparison unit is linked to each delay unit that corresponds to
  3341.         a recognition unit
  3342.    */
  3343.  
  3344.    krart_deleteTouchFlags();
  3345.  
  3346.  
  3347.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  3348.  
  3349.       if (UNIT_HAS_SITES (unit_ptr)) {
  3350.  
  3351.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  3352.  
  3353.       } else {
  3354.  
  3355.          count_inp = 0;
  3356.          count_spec = 0;
  3357.          count_del = 0;
  3358.  
  3359.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3360.  
  3361.             switch (link_ptr->to->lln) {
  3362.             case ARTMAP_DELa_LAY:
  3363.                if (link_ptr->to->lun == ARTMAP_DELa_REC_UNIT) {
  3364.                   count_del++;
  3365.                } else {
  3366.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3367.                } /*if*/
  3368.                break;
  3369.             case ARTMAP_INPa_LAY:
  3370.                if (UNIT_REFRESHED (link_ptr->to)) {
  3371.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3372.                } /*if*/
  3373.                link_ptr->to->flags |= UFLAG_REFRESH;
  3374.                count_inp++;
  3375.                break;
  3376.             case ARTMAP_SPECa_LAY:
  3377.                if (link_ptr->to->lun != ARTMAP_G1a_UNIT) {
  3378.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3379.                } /*if*/
  3380.                count_spec++;
  3381.                break;
  3382.             default :
  3383.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3384.             } /* switch */
  3385.  
  3386.          } /*FOR_ALL_LINKS*/
  3387.  
  3388.          if ((count_inp != 1) || (count_spec != 1) ||
  3389.              (count_del != ArtMap_NoOfRecUnits_a)
  3390.             )
  3391.          {
  3392.             TOPO_MSG_LINK_MISSING (unit_ptr);
  3393.          } /*if*/
  3394.  
  3395.       } /*if*/
  3396.  
  3397.    } /*while*/
  3398.  
  3399.    return (ret_code);
  3400.  
  3401. } /* kram_LinksToCmpUnits_a () */
  3402. /*___________________________________________________________________________*/
  3403.  
  3404.  
  3405.  
  3406.  
  3407. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  3408. static krui_err   kram_LinksToRecUnits_a (TopoPtrArray *topo_ptr)
  3409. {
  3410.    register struct Unit     *unit_ptr;
  3411.    register struct Link     *link_ptr;
  3412.  
  3413.    int                      count_cmp;
  3414.    int                      count_rst;
  3415.    int                      count_rg;
  3416.    int                      count_g2;
  3417.  
  3418.    krui_err                 ret_code = KRERR_NO_ERROR;
  3419.  
  3420.  
  3421.    /* - each recognition unit is linked to all comparison units
  3422.       - each recognition unit is linked to the reset general unit
  3423.       - each recognition unit is linked to exactly one local reset unit which
  3424.         itself is linked to only this recognition unit.
  3425.    */
  3426.  
  3427.    krart_deleteTouchFlags();
  3428.  
  3429.  
  3430.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  3431.  
  3432.       if (UNIT_HAS_SITES (unit_ptr)) {
  3433.  
  3434.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  3435.  
  3436.       } else {
  3437.  
  3438.          count_cmp = 0;
  3439.          count_rst = 0;
  3440.          count_rg  = 0;
  3441.          count_g2  = 0;
  3442.  
  3443.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3444.  
  3445.             switch (link_ptr->to->lln) {
  3446.             case ARTMAP_CMPa_LAY:
  3447.                count_cmp++;
  3448.                break;
  3449.             case ARTMAP_RSTa_LAY:
  3450.                if (UNIT_REFRESHED (link_ptr->to)) {
  3451.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3452.                } /*if*/
  3453.                link_ptr->to->flags |= UFLAG_REFRESH;
  3454.                count_rst++;
  3455.                break;
  3456.             case ARTMAP_SPECa_LAY:
  3457.                switch (link_ptr->to->lun) {
  3458.                case ARTMAP_RGa_UNIT:
  3459.                   count_rg++;
  3460.                   break;
  3461.                case ARTMAP_G2a_UNIT:
  3462.                   count_g2++;
  3463.                   break;
  3464.                default:
  3465.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3466.                   break;
  3467.                } /*switch*/
  3468.                break;
  3469.             default :
  3470.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3471.             } /* switch */
  3472.  
  3473.          } /*FOR_ALL_LINKS*/
  3474.  
  3475.          if ((count_rst != 1) || (count_rg != 1) || (count_g2 != 1) ||
  3476.              (count_cmp != ArtMap_NoOfInpUnits_a)
  3477.             )
  3478.          {
  3479.            TOPO_MSG_LINK_MISSING  (unit_ptr);
  3480.          } /*if*/
  3481.  
  3482.       } /*if*/
  3483.  
  3484.    } /*while*/
  3485.  
  3486.    return (ret_code);
  3487.  
  3488. } /* kram_LinksToRecUnits_a () */
  3489. /*___________________________________________________________________________*/
  3490.  
  3491.  
  3492.  
  3493. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  3494. static krui_err   kram_LinksToDelUnits_a (TopoPtrArray *topo_ptr)
  3495. {
  3496.    register struct Unit     *unit_ptr;
  3497.    register struct Link     *link_ptr;
  3498.  
  3499.    int                      count_rec;
  3500.    int                      count_del;
  3501.  
  3502.    krui_err                 ret_code = KRERR_NO_ERROR;
  3503.  
  3504.  
  3505.    /* There are different cases to distinguish
  3506.       1. the delay unit is one that corresponds to a recogniton unit
  3507.          then
  3508.               - it has only one incoming link which comes from the corresponding
  3509.                 recognition unit
  3510.  
  3511.       2. it is the first other delay unit then
  3512.               - it has links to all delay units that correspond to a
  3513.                 recognition unit
  3514.       3. it is the second other delay unit then
  3515.               - it has exactly one link to the first other delay unit
  3516.       4. it is the third other delay unit then
  3517.               - it has exactly one link to the second other delay unit.
  3518.    */
  3519.  
  3520.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  3521.  
  3522.       if (UNIT_HAS_SITES (unit_ptr)) {
  3523.  
  3524.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  3525.  
  3526.       } else {
  3527.  
  3528.          switch (unit_ptr->lun) {
  3529.  
  3530.          case ARTMAP_DELa_REC_UNIT:
  3531.  
  3532.             count_rec = 0;
  3533.  
  3534.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3535.  
  3536.                if (link_ptr->to->lln == ARTMAP_RECa_LAY) {
  3537.  
  3538.                   count_rec++;
  3539.                   if (UNIT_REFRESHED (link_ptr->to)) {
  3540.                      TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3541.                   } else {
  3542.                      link_ptr->to->flags |= UFLAG_REFRESH;
  3543.                   } /*if*/
  3544.  
  3545.                } else {
  3546.  
  3547.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3548.  
  3549.                } /*if*/
  3550.  
  3551.             } /*FOR_ALL_LINKS*/
  3552.  
  3553.             if (count_rec != 1) {
  3554.                TOPO_MSG_LINK_MISSING (unit_ptr);
  3555.             } /*if*/
  3556.  
  3557.             break;
  3558.  
  3559.          case ARTMAP_D1a_UNIT:
  3560.  
  3561.             count_del = 0;
  3562.  
  3563.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3564.  
  3565.                if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  3566.                    (link_ptr->to->lun == ARTMAP_DELa_REC_UNIT)
  3567.                   )
  3568.                {
  3569.                   count_del++;
  3570.                } else {
  3571.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3572.                } /*if*/
  3573.  
  3574.             } /*FOR_ALL_LINKS*/
  3575.  
  3576.             if (count_del != ArtMap_NoOfRecUnits_a) {
  3577.                TOPO_MSG_LINK_MISSING (unit_ptr);
  3578.             } /*if*/
  3579.  
  3580.             break;
  3581.  
  3582.          case ARTMAP_D2a_UNIT:
  3583.  
  3584.             count_del = 0;
  3585.  
  3586.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3587.  
  3588.                if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  3589.                    (link_ptr->to->lun == ARTMAP_D1a_UNIT)
  3590.                   )
  3591.                {
  3592.                   count_del++;
  3593.                } else {
  3594.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3595.                } /*if*/
  3596.  
  3597.             } /*FOR_ALL_LINKS*/
  3598.  
  3599.             if (count_del != 1) {
  3600.                TOPO_MSG_LINK_MISSING (unit_ptr);
  3601.             } /*if*/
  3602.  
  3603.             break;
  3604.  
  3605.          case ARTMAP_D3a_UNIT:
  3606.  
  3607.             count_del = 0;
  3608.  
  3609.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3610.  
  3611.                if ((link_ptr->to->lln == ARTMAP_DELa_LAY) &&
  3612.                    (link_ptr->to->lun == ARTMAP_D2a_UNIT)
  3613.                   )
  3614.                {
  3615.                   count_del++;
  3616.                } else {
  3617.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3618.                } /*if*/
  3619.  
  3620.             } /*FOR_ALL_LINKS*/
  3621.  
  3622.             if (count_del != 1) {
  3623.                TOPO_MSG_LINK_MISSING (unit_ptr);
  3624.             } /*if*/
  3625.  
  3626.             break;
  3627.  
  3628.          default :
  3629.             ARTMAP_RETURN_NET_ERROR (ret_code);
  3630.          } /* switch */
  3631.  
  3632.       } /*if*/
  3633.  
  3634.    } /*while*/
  3635.  
  3636.    return (ret_code);
  3637.  
  3638. } /* kram_LinksToDelUnits_a () */
  3639. /*___________________________________________________________________________*/
  3640.  
  3641.  
  3642.  
  3643. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  3644. static krui_err   kram_LinksToRstUnits_a (TopoPtrArray *topo_ptr)
  3645. {
  3646.    register struct Unit     *unit_ptr;
  3647.    register struct Link     *link_ptr;
  3648.  
  3649.    struct Site              *site_ptr,
  3650.                             *site_ptr1,
  3651.                             *site_ptr2;
  3652.  
  3653.  
  3654.  
  3655.    int                      count_rst;
  3656.    int                      count_spec;
  3657.    int                      count_del;
  3658.  
  3659.    krui_err                 ret_code = KRERR_NO_ERROR;
  3660.  
  3661.  
  3662.    /* - each local reset unit is linked to via site 1
  3663.       - each local reset unit is linked to the reset general unit via site 2
  3664.       - each local reset unit is linked to exactly one delay unit that
  3665.         corresponds to a recognition unit and which itself is linked
  3666.         to only this local reset unit, via site 2.
  3667.    */
  3668.  
  3669.    krart_deleteTouchFlags();
  3670.  
  3671.  
  3672.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  3673.  
  3674.       if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  3675.  
  3676.          TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  3677.  
  3678.       } else {
  3679.  
  3680.          count_rst = 0;
  3681.          count_spec = 0;
  3682.          count_del = 0;
  3683.  
  3684.          site_ptr1 = NULL;
  3685.          site_ptr2 = NULL;
  3686.  
  3687.          FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  3688.  
  3689.             switch (link_ptr->to->lln) {
  3690.             case ARTMAP_RSTa_LAY:
  3691.  
  3692.                count_rst++;
  3693.  
  3694.                if (link_ptr->to != unit_ptr) {
  3695.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3696.                } /*if*/
  3697.  
  3698.                site_ptr1 = site_ptr;
  3699.  
  3700.                if (site_ptr1 == site_ptr2) {
  3701.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3702.                } /*if*/
  3703.  
  3704.                break;
  3705.  
  3706.             case ARTMAP_DELa_LAY:
  3707.  
  3708.                if (UNIT_REFRESHED (link_ptr->to)) {
  3709.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3710.                } /*if*/
  3711.  
  3712.                link_ptr->to->flags |= UFLAG_REFRESH;
  3713.  
  3714.                count_del++;
  3715.  
  3716.                if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  3717.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3718.                } /*if*/
  3719.  
  3720.                site_ptr2 = site_ptr;
  3721.  
  3722.                if (site_ptr1 == site_ptr2) {
  3723.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3724.                } /*if*/
  3725.  
  3726.                break;
  3727.  
  3728.             case ARTMAP_SPECa_LAY:
  3729.  
  3730.                if (link_ptr->to->lun != ARTMAP_RGa_UNIT) {
  3731.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3732.                } /*if*/
  3733.  
  3734.                count_spec++;
  3735.  
  3736.                if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  3737.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3738.                } /*if*/
  3739.  
  3740.                site_ptr2 = site_ptr;
  3741.  
  3742.                if (site_ptr1 == site_ptr2) {
  3743.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3744.                } /*if*/
  3745.  
  3746.                break;
  3747.  
  3748.             default :
  3749.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3750.             } /* switch */
  3751.  
  3752.          } /*FOR_ALL_SITES_AND_LINKS*/
  3753.  
  3754.          if ((count_rst != 1) || (count_spec != 1) || (count_del != 1)) {
  3755.             TOPO_MSG_LINK_MISSING (unit_ptr);
  3756.          } /*if*/
  3757.  
  3758.       } /*if*/
  3759.  
  3760.    } /*while*/
  3761.  
  3762.    return (ret_code);
  3763.  
  3764. } /* kram_LinksToRstUnits_a () */
  3765. /*___________________________________________________________________________*/
  3766.  
  3767.  
  3768.  
  3769.  
  3770. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  3771. static krui_err   kram_LinksToSpecUnits_a (TopoPtrArray *topo_ptr)
  3772. {
  3773.    register struct Unit     *unit_ptr;
  3774.    register struct Link     *link_ptr;
  3775.  
  3776.    struct Site              *site_ptr,
  3777.                             *site_ptr1,
  3778.                             *site_ptr2;
  3779.  
  3780.  
  3781.  
  3782.    int                      count_rst;
  3783.    int                      count_del;
  3784.    int                      count_inp;
  3785.    int                      count_rec;
  3786.    int                      count_cmp;
  3787.    int                      count_ri;
  3788.    int                      count_rc;
  3789.    int                      count_rg;
  3790.    int                      count_rho;
  3791.    int                      count_g2;
  3792.    int                      count_drho;
  3793.  
  3794.    krui_err                 ret_code = KRERR_NO_ERROR;
  3795.  
  3796.  
  3797.    /* topo_ptr points to classified unit which has two links:
  3798.       1. to d3a unit
  3799.       2. to reset general unit
  3800.    */
  3801.  
  3802.    unit_ptr = *(*topo_ptr)++;
  3803.  
  3804.    if (UNIT_HAS_SITES (unit_ptr)) {
  3805.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  3806.    } /*if*/
  3807.  
  3808.    count_del = 0;
  3809.    count_rg  = 0;
  3810.    count_g2  = 0;
  3811.  
  3812.    site_ptr1 = NULL;
  3813.    site_ptr2 = NULL;
  3814.  
  3815.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3816.  
  3817.       switch (link_ptr->to->lln) {
  3818.       case ARTMAP_DELa_LAY:
  3819.  
  3820.          count_del++;
  3821.  
  3822.          if (link_ptr->to->lun != ARTMAP_D3a_UNIT) {
  3823.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3824.          } /*if*/
  3825.  
  3826.          break;
  3827.  
  3828.       case ARTMAP_SPECa_LAY:
  3829.  
  3830.          switch (link_ptr->to->lun) {
  3831.          case ARTMAP_RGa_UNIT:
  3832.             count_rg++;
  3833.             break;
  3834.          case ARTMAP_G2a_UNIT:
  3835.             count_g2++;
  3836.             break;
  3837.          default:
  3838.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3839.             break;
  3840.          } /*switch*/
  3841.  
  3842.          break;
  3843.  
  3844.       default :
  3845.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3846.       } /* switch */
  3847.  
  3848.    } /*FOR_ALL_LINKS*/
  3849.  
  3850.    if ((count_del != 1) || (count_rg != 1) || count_g2 != 1) {
  3851.       TOPO_MSG_LINK_MISSING (unit_ptr);
  3852.    } /*if*/
  3853.  
  3854.  
  3855.    /* topo_ptr points to not classifiable unit which is linked to all
  3856.       local reset units
  3857.    */
  3858.  
  3859.    unit_ptr = *(*topo_ptr)++;
  3860.  
  3861.    if (UNIT_HAS_SITES (unit_ptr)) {
  3862.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  3863.    } /*if*/
  3864.  
  3865.    count_rst = 0;
  3866.  
  3867.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  3868.  
  3869.       if (link_ptr->to->lln != ARTMAP_RSTa_LAY) {
  3870.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3871.       } /*if*/
  3872.  
  3873.       count_rst++;
  3874.  
  3875.    } /*FOR_ALL_LINKS*/
  3876.  
  3877.    if (count_rst != ArtMap_NoOfRecUnits_a) {
  3878.       TOPO_MSG_LINK_MISSING (unit_ptr);
  3879.    } /*if*/
  3880.  
  3881.  
  3882.    /* topo_ptr points to Gain 1 unit which is linked to all input units
  3883.       via site 1 and to all recognition units via site 2
  3884.    */
  3885.  
  3886.    unit_ptr = *(*topo_ptr)++;
  3887.  
  3888.    if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  3889.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  3890.    } /*if*/
  3891.  
  3892.    count_inp = 0;
  3893.    count_rec = 0;
  3894.  
  3895.    site_ptr1 = NULL;
  3896.    site_ptr2 = NULL;
  3897.  
  3898.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  3899.  
  3900.       switch (link_ptr->to->lln) {
  3901.  
  3902.       case ARTMAP_RECa_LAY :
  3903.  
  3904.          count_rec++;
  3905.  
  3906.          if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  3907.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3908.          } /*if*/
  3909.  
  3910.          site_ptr2 = site_ptr;
  3911.  
  3912.          if (site_ptr1 == site_ptr2) {
  3913.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3914.          } /*if*/
  3915.  
  3916.          break;
  3917.  
  3918.       case ARTMAP_INPa_LAY :
  3919.  
  3920.          count_inp++;
  3921.  
  3922.          if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  3923.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3924.          } /*if*/
  3925.  
  3926.          site_ptr1 = site_ptr;
  3927.  
  3928.          if (site_ptr1 == site_ptr2) {
  3929.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3930.          } /*if*/
  3931.  
  3932.          break;
  3933.  
  3934.       default :
  3935.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  3936.  
  3937.       } /*switch*/
  3938.  
  3939.    } /*FOR_ALL_SITES_AND_LINKS*/
  3940.  
  3941.    if ((count_inp != ArtMap_NoOfInpUnits_a) ||
  3942.        (count_rec != ArtMap_NoOfRecUnits_a)
  3943.       )
  3944.    {
  3945.       TOPO_MSG_LINK_MISSING (unit_ptr);
  3946.    } /*if*/
  3947.  
  3948.  
  3949.  
  3950.    /* topo_ptr points to reset I unit which is linked to all input units
  3951.       via one site and to the RHO unit via the other site
  3952.    */
  3953.  
  3954.    unit_ptr = *(*topo_ptr)++;
  3955.  
  3956.    if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  3957.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  3958.    } /*if*/
  3959.  
  3960.    count_inp = 0;
  3961.    count_rho = 0;
  3962.  
  3963.    site_ptr1 = NULL;
  3964.    site_ptr2 = NULL;
  3965.  
  3966.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  3967.  
  3968.       switch (link_ptr->to->lln) {
  3969.  
  3970.       case ARTMAP_INPa_LAY:
  3971.  
  3972.          count_inp++;
  3973.  
  3974.          if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  3975.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3976.          } /*if*/
  3977.  
  3978.          site_ptr1 = site_ptr;
  3979.  
  3980.          if (site_ptr1 == site_ptr2) {
  3981.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3982.          } /*if*/
  3983.  
  3984.          break;
  3985.  
  3986.       case ARTMAP_SPECa_LAY:
  3987.  
  3988.          if (link_ptr->to->lun != ARTMAP_RHOa_UNIT) {
  3989.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3990.          } /*if*/
  3991.  
  3992.          count_rho++;
  3993.  
  3994.          if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  3995.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  3996.          } /*if*/
  3997.  
  3998.          site_ptr2 = site_ptr;
  3999.  
  4000.          if (site_ptr2 == site_ptr1) {
  4001.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4002.          } /*if*/
  4003.  
  4004.          break;
  4005.  
  4006.       default:
  4007.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4008.  
  4009.       } /*switch*/
  4010.  
  4011.    } /*FOR_ALL_LINKS*/
  4012.  
  4013.    if ((count_inp != ArtMap_NoOfInpUnits_a) || (count_rho != 1)) {
  4014.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4015.    } /*if*/
  4016.  
  4017.  
  4018.  
  4019.    /* topo_ptr points to reset C unit which is linked to all comparison units
  4020.    */
  4021.  
  4022.    unit_ptr = *(*topo_ptr)++;
  4023.  
  4024.    if (UNIT_HAS_SITES (unit_ptr)) {
  4025.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4026.    } /*if*/
  4027.  
  4028.    count_cmp = 0;
  4029.  
  4030.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4031.  
  4032.       if (link_ptr->to->lln != ARTMAP_CMPa_LAY) {
  4033.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4034.       } /*if*/
  4035.  
  4036.       count_cmp++;
  4037.  
  4038.    } /*FOR_ALL_LINKS*/
  4039.  
  4040.    if (count_cmp != ArtMap_NoOfInpUnits_a) {
  4041.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4042.    } /*if*/
  4043.  
  4044.  
  4045.    /* topo_ptr points to reset general unit which is linked to
  4046.       the reset I unit and the reset C unit
  4047.    */
  4048.  
  4049.    unit_ptr = *(*topo_ptr)++;
  4050.  
  4051.    if (UNIT_HAS_SITES (unit_ptr)) {
  4052.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4053.    } /*if*/
  4054.  
  4055.    count_ri = 0;
  4056.    count_rc = 0;
  4057.  
  4058.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4059.  
  4060.       if (link_ptr->to->lln != ARTMAP_SPECa_LAY) {
  4061.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4062.       } /*if*/
  4063.  
  4064.       if (link_ptr->to->lun == ARTMAP_RIa_UNIT) {
  4065.          count_ri++;
  4066.          continue;
  4067.       } /*if*/
  4068.  
  4069.       if (link_ptr->to->lun == ARTMAP_RCa_UNIT) {
  4070.          count_rc++;
  4071.          continue;
  4072.       } /*if*/
  4073.  
  4074.       TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4075.  
  4076.    } /*FOR_ALL_LINKS*/
  4077.  
  4078.  
  4079.    if ((count_ri != 1) || (count_rc != 1)) {
  4080.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4081.    } /*if*/
  4082.  
  4083.  
  4084.  
  4085.  
  4086.    /* topo_ptr points to RHOa unit which has an incoming link
  4087.       from itself and one from the drho unit.
  4088.    */
  4089.  
  4090.    unit_ptr = *(*topo_ptr)++;
  4091.  
  4092.    if (UNIT_HAS_SITES (unit_ptr)) {
  4093.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4094.    } /*if*/
  4095.  
  4096.    count_rho = 0;
  4097.    count_drho = 0;
  4098.  
  4099.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4100.  
  4101.       switch (link_ptr->to->lln) {
  4102.       case ARTMAP_SPECa_LAY:
  4103.          if (link_ptr->to->lun == ARTMAP_RHOa_UNIT) {
  4104.             count_rho++;
  4105.          } else {
  4106.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4107.          }  /*if*/
  4108.          break;
  4109.       case ARTMAP_SPEC_LAY:
  4110.          if (link_ptr->to->lun == ARTMAP_DRHO_UNIT) {
  4111.             count_drho++;
  4112.          } else {
  4113.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4114.          } /*if*/
  4115.          break;
  4116.       default:
  4117.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4118.       } /*switch*/
  4119.  
  4120.    } /*FOR_ALL_LINKS*/
  4121.  
  4122.    if ((count_rho != 1) || (count_drho != 1)) {
  4123.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4124.    } /*if*/
  4125.  
  4126.  
  4127.  
  4128.  
  4129.    /* topo_ptr points to g2a unit which has incoming links
  4130.       from all inpa units
  4131.    */
  4132.  
  4133.    unit_ptr = *(*topo_ptr)++;
  4134.  
  4135.    if (UNIT_HAS_SITES (unit_ptr)) {
  4136.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4137.    } /*if*/
  4138.  
  4139.    count_inp = 0;
  4140.  
  4141.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4142.  
  4143.      if (link_ptr->to->lln == ARTMAP_INPa_LAY) {
  4144.         count_inp++;
  4145.      } else {
  4146.         TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4147.      } /*if*/
  4148.  
  4149.    } /*FOR_ALL_LINKS*/
  4150.  
  4151.    if (count_inp != ArtMap_NoOfInpUnits_a) {
  4152.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4153.    } /*if*/
  4154.  
  4155.    (*topo_ptr)++;  /* increment topo_ptr to next used position in array */
  4156.  
  4157.    return (ret_code);
  4158.  
  4159. } /* kram_LinksToSpecUnits_a () */
  4160. /*___________________________________________________________________________*/
  4161.  
  4162.  
  4163.  
  4164.  
  4165.  
  4166. /************* functions for checking links of ARTb
  4167. *************/
  4168.  
  4169.  
  4170.  
  4171.  
  4172. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  4173. static krui_err  kram_LinksToInpUnits_b (TopoPtrArray *topo_ptr)
  4174. {
  4175.    register struct Unit   *unit_ptr;
  4176.  
  4177.    krui_err               ret_code = KRERR_NO_ERROR;
  4178.  
  4179.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  4180.  
  4181.       if (UNIT_HAS_INPUTS (unit_ptr)) {
  4182.          topo_msg.error_code = KRERR_I_UNITS_CONNECT;
  4183.          topo_msg.dest_error_unit = unit_ptr-unit_array;
  4184.          topo_msg.src_error_unit = 0;
  4185.          ret_code = topo_msg.error_code;
  4186.       } /*if*/
  4187.  
  4188.    } /*while*/
  4189.  
  4190.    return (ret_code);
  4191.  
  4192. } /* kram_LinksToInpUnits_b () */
  4193. /*___________________________________________________________________________*/
  4194.  
  4195.  
  4196.  
  4197. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  4198. static krui_err   kram_LinksToCmpUnits_b (TopoPtrArray *topo_ptr)
  4199. {
  4200.    register struct Unit     *unit_ptr;
  4201.    register struct Link     *link_ptr;
  4202.  
  4203.    int                      count_inp,
  4204.                             count_spec,
  4205.                             count_del;
  4206.  
  4207.  
  4208.    krui_err                 ret_code = KRERR_NO_ERROR;
  4209.  
  4210.  
  4211.    /* - each comparison unit has a link to exactly one input unit which itself
  4212.         is connected to only this comparison unit and no other.
  4213.       - each comparison unit is linked to the gain 1 unit
  4214.       - each comparison unit is linked to each delay unit that corresponds to
  4215.         a recognition unit
  4216.    */
  4217.  
  4218.    krart_deleteTouchFlags();
  4219.  
  4220.  
  4221.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  4222.  
  4223.       if (UNIT_HAS_SITES (unit_ptr)) {
  4224.  
  4225.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4226.  
  4227.       } else {
  4228.  
  4229.          count_inp = 0;
  4230.          count_spec = 0;
  4231.          count_del = 0;
  4232.  
  4233.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4234.  
  4235.             switch (link_ptr->to->lln) {
  4236.             case ARTMAP_DELb_LAY:
  4237.                if (link_ptr->to->lun == ARTMAP_DELb_REC_UNIT) {
  4238.                   count_del++;
  4239.                } else {
  4240.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4241.                } /*if*/
  4242.                break;
  4243.             case ARTMAP_INPb_LAY:
  4244.                if (UNIT_REFRESHED (link_ptr->to)) {
  4245.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4246.                } /*if*/
  4247.                link_ptr->to->flags |= UFLAG_REFRESH;
  4248.                count_inp++;
  4249.                break;
  4250.             case ARTMAP_SPECb_LAY:
  4251.                if (link_ptr->to->lun != ARTMAP_G1b_UNIT) {
  4252.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4253.                } /*if*/
  4254.                count_spec++;
  4255.                break;
  4256.             default :
  4257.               TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4258.             } /* switch */
  4259.  
  4260.          } /*FOR_ALL_LINKS*/
  4261.  
  4262.          if ((count_inp != 1) || (count_spec != 1) ||
  4263.              (count_del != ArtMap_NoOfRecUnits_b)
  4264.             )
  4265.          {
  4266.             TOPO_MSG_LINK_MISSING (unit_ptr);
  4267.          } /*if*/
  4268.  
  4269.       } /*if*/
  4270.  
  4271.    } /*while*/
  4272.  
  4273.    return (ret_code);
  4274.  
  4275. } /* kram_LinksToCmpUnits_b () */
  4276. /*___________________________________________________________________________*/
  4277.  
  4278.  
  4279.  
  4280.  
  4281. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  4282. static krui_err   kram_LinksToRecUnits_b (TopoPtrArray *topo_ptr)
  4283. {
  4284.    register struct Unit     *unit_ptr;
  4285.    register struct Link     *link_ptr;
  4286.  
  4287.    int                      count_cmp;
  4288.    int                      count_rst;
  4289.    int                      count_rg;
  4290.    int                      count_g2;
  4291.  
  4292.    krui_err                 ret_code = KRERR_NO_ERROR;
  4293.  
  4294.  
  4295.    /* - each recognition unit is linked to all comparison units
  4296.       - each recognition unit is linked to the reset general unit
  4297.       - each recognition unit is linked to exactly one local reset unit which
  4298.         itself is linked to only this recognition unit.
  4299.    */
  4300.  
  4301.    krart_deleteTouchFlags();
  4302.  
  4303.  
  4304.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  4305.  
  4306.       if (UNIT_HAS_SITES (unit_ptr)) {
  4307.  
  4308.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4309.  
  4310.       } else {
  4311.  
  4312.          count_cmp = 0;
  4313.          count_rst = 0;
  4314.          count_rg  = 0;
  4315.          count_g2  = 0;
  4316.  
  4317.          FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4318.  
  4319.             switch (link_ptr->to->lln) {
  4320.             case ARTMAP_CMPb_LAY:
  4321.                count_cmp++;
  4322.                break;
  4323.             case ARTMAP_RSTb_LAY:
  4324.                if (UNIT_REFRESHED (link_ptr->to)) {
  4325.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4326.                } /*if*/
  4327.                link_ptr->to->flags |= UFLAG_REFRESH;
  4328.                count_rst++;
  4329.                break;
  4330.             case ARTMAP_SPECb_LAY:
  4331.                switch (link_ptr->to->lun) {
  4332.                case ARTMAP_RGb_UNIT:
  4333.                   count_rg++;
  4334.                   break;
  4335.                case ARTMAP_G2b_UNIT:
  4336.                   count_g2++;
  4337.                   break;
  4338.                default:
  4339.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4340.                   break;
  4341.                } /*switch*/
  4342.                break;
  4343.             default :
  4344.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4345.             } /* switch */
  4346.  
  4347.          } /*FOR_ALL_LINKS*/
  4348.  
  4349.          if ((count_rst != 1) || (count_rg != 1) || (count_g2 != 1) ||
  4350.              (count_cmp != ArtMap_NoOfInpUnits_b)
  4351.             )
  4352.          {
  4353.             TOPO_MSG_LINK_MISSING  (unit_ptr);
  4354.          } /*if*/
  4355.  
  4356.       } /*if*/
  4357.  
  4358.    } /*while*/
  4359.  
  4360.    return (ret_code);
  4361.  
  4362. } /* kram_LinksToRecUnits_b () */
  4363. /*___________________________________________________________________________*/
  4364.  
  4365.  
  4366.  
  4367. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  4368. static krui_err   kram_LinksToDelUnits_b (TopoPtrArray *topo_ptr)
  4369. {
  4370.    register struct Unit     *unit_ptr;
  4371.    register struct Link     *link_ptr;
  4372.  
  4373.    int                      count_rec;
  4374.    int                      count_del;
  4375.    int                      count_map;
  4376.  
  4377.    krui_err                 ret_code = KRERR_NO_ERROR;
  4378.  
  4379.  
  4380.    /* There are different cases to distinguish
  4381.       1. the delay unit is one that corresponds to a recogniton unit
  4382.          then
  4383.               - it has  one incoming link which comes from the corresponding
  4384.                 recognition unit
  4385.               - and one incoming link, which comes from the corresponding
  4386.                 map-unit.
  4387.  
  4388.       2. it is the first other delay unit then
  4389.               - it has links to all delay units that correspond to a
  4390.                 recognition unit
  4391.       3. it is the second other delay unit then
  4392.               - it has exactly one link to the first other delay unit
  4393.       4. it is the third other delay unit then
  4394.               - it has exactly one link to the second other delay unit.
  4395.    */
  4396.  
  4397.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  4398.  
  4399.       if (UNIT_HAS_SITES (unit_ptr)) {
  4400.  
  4401.          ARTMAP_RETURN_NET_ERROR (ret_code);
  4402.  
  4403.       } else {
  4404.  
  4405.          switch (unit_ptr->lun) {
  4406.  
  4407.          case ARTMAP_DELb_REC_UNIT:
  4408.  
  4409.             count_rec = 0;
  4410.             count_map = 0;
  4411.  
  4412.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4413.  
  4414.                switch (link_ptr->to->lln) {
  4415.                case ARTMAP_RECb_LAY:
  4416.                   count_rec++;
  4417.                   if (UNIT_REFRESHED (link_ptr->to)) {
  4418.                      TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4419.                   } else {
  4420.                      link_ptr->to->flags |= UFLAG_REFRESH;
  4421.                   } /*if*/
  4422.                   break;
  4423.                case ARTMAP_MAP_LAY:
  4424.                   count_map++;
  4425.                   if (UNIT_REFRESHED (link_ptr->to)) {
  4426.                      TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4427.                   } else {
  4428.                      link_ptr->to->flags |= UFLAG_REFRESH;
  4429.                   } /*if*/
  4430.                   break;
  4431.                default:
  4432.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4433.                } /*switch*/
  4434.  
  4435.             } /*FOR_ALL_LINKS*/
  4436.  
  4437.             if ((count_rec != 1) || (count_map != 1)) {
  4438.                TOPO_MSG_LINK_MISSING (unit_ptr);
  4439.             } /*if*/
  4440.  
  4441.             break;
  4442.  
  4443.          case ARTMAP_D1b_UNIT:
  4444.  
  4445.             count_del = 0;
  4446.  
  4447.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4448.  
  4449.                if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  4450.                    (link_ptr->to->lun == ARTMAP_DELb_REC_UNIT)
  4451.                   )
  4452.                {
  4453.                   count_del++;
  4454.                } else {
  4455.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4456.                } /*if*/
  4457.  
  4458.             } /*FOR_ALL_LINKS*/
  4459.  
  4460.             if (count_del != ArtMap_NoOfRecUnits_b) {
  4461.                TOPO_MSG_LINK_MISSING (unit_ptr);
  4462.             } /*if*/
  4463.  
  4464.             break;
  4465.  
  4466.          case ARTMAP_D2b_UNIT:
  4467.  
  4468.             count_del = 0;
  4469.  
  4470.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4471.  
  4472.                if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  4473.                    (link_ptr->to->lun == ARTMAP_D1b_UNIT)
  4474.                   )
  4475.                {
  4476.                   count_del++;
  4477.                } else {
  4478.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4479.                } /*if*/
  4480.  
  4481.             } /*FOR_ALL_LINKS*/
  4482.  
  4483.             if (count_del != 1) {
  4484.                TOPO_MSG_LINK_MISSING (unit_ptr);
  4485.             } /*if*/
  4486.  
  4487.             break;
  4488.  
  4489.          case ARTMAP_D3b_UNIT:
  4490.  
  4491.             count_del = 0;
  4492.  
  4493.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4494.  
  4495.                if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  4496.                    (link_ptr->to->lun == ARTMAP_D2b_UNIT)
  4497.                   )
  4498.                {
  4499.                   count_del++;
  4500.                } else {
  4501.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4502.                } /*if*/
  4503.  
  4504.             } /*FOR_ALL_LINKS*/
  4505.  
  4506.             if (count_del != 1) {
  4507.                TOPO_MSG_LINK_MISSING (unit_ptr);
  4508.             } /*if*/
  4509.  
  4510.             break;
  4511.  
  4512.          default :
  4513.             ARTMAP_RETURN_NET_ERROR (ret_code);
  4514.          } /* switch */
  4515.  
  4516.       } /*if*/
  4517.  
  4518.    } /*while*/
  4519.  
  4520.    return (ret_code);
  4521.  
  4522. } /* kram_LinksToDelUnits_b () */
  4523. /*___________________________________________________________________________*/
  4524.  
  4525.  
  4526.  
  4527. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  4528. static krui_err   kram_LinksToRstUnits_b (TopoPtrArray *topo_ptr)
  4529. {
  4530.    register struct Unit     *unit_ptr;
  4531.    register struct Link     *link_ptr;
  4532.  
  4533.    struct Site              *site_ptr,
  4534.                             *site_ptr1,
  4535.                             *site_ptr2;
  4536.  
  4537.  
  4538.  
  4539.    int                      count_rst;
  4540.    int                      count_spec;
  4541.    int                      count_del;
  4542.  
  4543.    krui_err                 ret_code = KRERR_NO_ERROR;
  4544.  
  4545.  
  4546.    /* - each local reset unit is linked to via site 1
  4547.       - each local reset unit is linked to the reset general unit via site 2
  4548.       - each local reset unit is linked to exactly one delay unit that
  4549.         corresponds to a recognition unit and which itself is linked
  4550.         to only this local reset unit, via site 2.
  4551.    */
  4552.  
  4553.    krart_deleteTouchFlags();
  4554.  
  4555.  
  4556.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  4557.  
  4558.       if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  4559.  
  4560.          TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  4561.  
  4562.       } else {
  4563.  
  4564.          count_rst = 0;
  4565.          count_spec = 0;
  4566.          count_del = 0;
  4567.  
  4568.          site_ptr1 = NULL;
  4569.          site_ptr2 = NULL;
  4570.  
  4571.          FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  4572.  
  4573.             switch (link_ptr->to->lln) {
  4574.             case ARTMAP_RSTb_LAY:
  4575.  
  4576.                count_rst++;
  4577.  
  4578.                if (link_ptr->to != unit_ptr) {
  4579.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4580.                } /*if*/
  4581.  
  4582.                site_ptr1 = site_ptr;
  4583.  
  4584.                if (site_ptr1 == site_ptr2) {
  4585.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4586.                } /*if*/
  4587.  
  4588.                break;
  4589.  
  4590.             case ARTMAP_DELb_LAY:
  4591.  
  4592.                if (UNIT_REFRESHED (link_ptr->to)) {
  4593.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4594.                } /*if*/
  4595.  
  4596.                link_ptr->to->flags |= UFLAG_REFRESH;
  4597.  
  4598.                count_del++;
  4599.  
  4600.                if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  4601.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4602.                } /*if*/
  4603.  
  4604.                site_ptr2 = site_ptr;
  4605.  
  4606.                if (site_ptr1 == site_ptr2) {
  4607.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4608.                } /*if*/
  4609.  
  4610.                break;
  4611.  
  4612.             case ARTMAP_SPECb_LAY:
  4613.  
  4614.                if (link_ptr->to->lun != ARTMAP_RGb_UNIT) {
  4615.                   TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4616.                } /*if*/
  4617.  
  4618.                count_spec++;
  4619.  
  4620.                if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  4621.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4622.                } /*if*/
  4623.  
  4624.                site_ptr2 = site_ptr;
  4625.  
  4626.                if (site_ptr1 == site_ptr2) {
  4627.                   TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4628.                } /*if*/
  4629.  
  4630.                break;
  4631.  
  4632.             default :
  4633.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4634.             } /* switch */
  4635.  
  4636.          } /*FOR_ALL_SITES_AND_LINKS*/
  4637.  
  4638.          if ((count_rst != 1) || (count_spec != 1) || (count_del != 1)) {
  4639.             TOPO_MSG_LINK_MISSING (unit_ptr);
  4640.          } /*if*/
  4641.  
  4642.       } /*if*/
  4643.  
  4644.    } /*while*/
  4645.  
  4646.    return (ret_code);
  4647.  
  4648. } /* kram_LinksToRstUnits_b () */
  4649. /*___________________________________________________________________________*/
  4650.  
  4651.  
  4652.  
  4653.  
  4654. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  4655. static krui_err   kram_LinksToSpecUnits_b (TopoPtrArray *topo_ptr)
  4656. {
  4657.    register struct Unit     *unit_ptr;
  4658.    register struct Link     *link_ptr;
  4659.  
  4660.    struct Site              *site_ptr,
  4661.                             *site_ptr1,
  4662.                             *site_ptr2;
  4663.  
  4664.  
  4665.  
  4666.    int                      count_rst;
  4667.    int                      count_del;
  4668.    int                      count_inp;
  4669.    int                      count_rec;
  4670.    int                      count_cmp;
  4671.    int                      count_ri;
  4672.    int                      count_rc;
  4673.    int                      count_rg;
  4674.    int                      count_rho;
  4675.    int                      count_g2;
  4676.  
  4677.    krui_err                 ret_code = KRERR_NO_ERROR;
  4678.  
  4679.  
  4680.    /* topo_ptr points to classified unit which has two links:
  4681.       1. to d3b unit
  4682.       2. to reset general unit
  4683.    */
  4684.  
  4685.    unit_ptr = *(*topo_ptr)++;
  4686.  
  4687.    if (UNIT_HAS_SITES (unit_ptr)) {
  4688.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4689.    } /*if*/
  4690.  
  4691.    count_del = 0;
  4692.    count_rg  = 0;
  4693.    count_g2  = 0;
  4694.  
  4695.    site_ptr1 = NULL;
  4696.    site_ptr2 = NULL;
  4697.  
  4698.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4699.  
  4700.       switch (link_ptr->to->lln) {
  4701.       case ARTMAP_DELb_LAY:
  4702.  
  4703.          count_del++;
  4704.  
  4705.          if (link_ptr->to->lun != ARTMAP_D3b_UNIT) {
  4706.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4707.          } /*if*/
  4708.  
  4709.          break;
  4710.  
  4711.       case ARTMAP_SPECb_LAY:
  4712.  
  4713.          switch (link_ptr->to->lun) {
  4714.          case ARTMAP_RGb_UNIT:
  4715.             count_rg++;
  4716.             break;
  4717.          case ARTMAP_G2b_UNIT:
  4718.             count_g2++;
  4719.             break;
  4720.          default:
  4721.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4722.             break;
  4723.          } /*switch*/
  4724.  
  4725.          break;
  4726.  
  4727.       default :
  4728.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4729.       } /* switch */
  4730.  
  4731.    } /*FOR_ALL_LINKS*/
  4732.  
  4733.    if ((count_del != 1) || (count_rg != 1) || (count_g2 != 1))
  4734.    {
  4735.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4736.    } /*if*/
  4737.  
  4738.  
  4739.    /* topo_ptr points to not classifiable unit which is linked to all
  4740.       local reset units
  4741.    */
  4742.  
  4743.    unit_ptr = *(*topo_ptr)++;
  4744.  
  4745.    if (UNIT_HAS_SITES (unit_ptr)) {
  4746.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4747.    } /*if*/
  4748.  
  4749.    count_rst = 0;
  4750.  
  4751.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4752.  
  4753.       if (link_ptr->to->lln != ARTMAP_RSTb_LAY) {
  4754.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4755.       } /*if*/
  4756.  
  4757.       count_rst++;
  4758.  
  4759.    } /*FOR_ALL_LINKS*/
  4760.  
  4761.    if (count_rst != ArtMap_NoOfRecUnits_b) {
  4762.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4763.    } /*if*/
  4764.  
  4765.  
  4766.    /* topo_ptr points to Gain 1 unit which is linked to all input units
  4767.       via site 1 and to all recognition units via site 2
  4768.    */
  4769.  
  4770.    unit_ptr = *(*topo_ptr)++;
  4771.  
  4772.    if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  4773.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  4774.    } /*if*/
  4775.  
  4776.    count_inp = 0;
  4777.    count_rec = 0;
  4778.  
  4779.    site_ptr1 = NULL;
  4780.    site_ptr2 = NULL;
  4781.  
  4782.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  4783.  
  4784.       switch (link_ptr->to->lln) {
  4785.  
  4786.       case ARTMAP_RECb_LAY :
  4787.  
  4788.          count_rec++;
  4789.  
  4790.          if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  4791.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4792.          } /*if*/
  4793.  
  4794.          site_ptr2 = site_ptr;
  4795.  
  4796.          if (site_ptr1 == site_ptr2) {
  4797.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4798.          } /*if*/
  4799.  
  4800.          break;
  4801.  
  4802.       case ARTMAP_INPb_LAY :
  4803.  
  4804.          count_inp++;
  4805.  
  4806.          if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  4807.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4808.          } /*if*/
  4809.  
  4810.          site_ptr1 = site_ptr;
  4811.  
  4812.          if (site_ptr1 == site_ptr2) {
  4813.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4814.          } /*if*/
  4815.  
  4816.          break;
  4817.  
  4818.       default :
  4819.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4820.  
  4821.       } /*switch*/
  4822.  
  4823.    } /*FOR_ALL_SITES_AND_LINKS*/
  4824.  
  4825.    if ((count_inp != ArtMap_NoOfInpUnits_b) ||
  4826.        (count_rec != ArtMap_NoOfRecUnits_b)
  4827.       )
  4828.    {
  4829.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4830.    } /*if*/
  4831.  
  4832.  
  4833.  
  4834.    /* topo_ptr points to reset I unit which is linked to all input units
  4835.       via one site and to the RHO unit via the other site
  4836.    */
  4837.  
  4838.    unit_ptr = *(*topo_ptr)++;
  4839.  
  4840.    if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  4841.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  4842.    } /*if*/
  4843.  
  4844.    count_inp = 0;
  4845.    count_rho = 0;
  4846.  
  4847.    site_ptr1 = NULL;
  4848.    site_ptr2 = NULL;
  4849.  
  4850.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  4851.  
  4852.       switch (link_ptr->to->lln) {
  4853.  
  4854.       case ARTMAP_INPb_LAY:
  4855.  
  4856.          count_inp++;
  4857.  
  4858.          if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  4859.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4860.          } /*if*/
  4861.  
  4862.          site_ptr1 = site_ptr;
  4863.  
  4864.          if (site_ptr1 == site_ptr2) {
  4865.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4866.          } /*if*/
  4867.  
  4868.          break;
  4869.  
  4870.       case ARTMAP_SPECb_LAY:
  4871.  
  4872.          if (link_ptr->to->lun != ARTMAP_RHOb_UNIT) {
  4873.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4874.          } /*if*/
  4875.  
  4876.          count_rho++;
  4877.  
  4878.          if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  4879.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4880.          } /*if*/
  4881.  
  4882.          site_ptr2 = site_ptr;
  4883.  
  4884.          if (site_ptr2 == site_ptr1) {
  4885.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  4886.          } /*if*/
  4887.  
  4888.          break;
  4889.  
  4890.       default:
  4891.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4892.  
  4893.       } /*switch*/
  4894.  
  4895.    } /*FOR_ALL_LINKS*/
  4896.  
  4897.    if ((count_inp != ArtMap_NoOfInpUnits_b) || (count_rho != 1)) {
  4898.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4899.    } /*if*/
  4900.  
  4901.  
  4902.  
  4903.    /* topo_ptr points to reset C unit which is linked to all comparison units
  4904.    */
  4905.  
  4906.    unit_ptr = *(*topo_ptr)++;
  4907.  
  4908.    if (UNIT_HAS_SITES (unit_ptr)) {
  4909.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4910.    } /*if*/
  4911.  
  4912.    count_cmp = 0;
  4913.  
  4914.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4915.  
  4916.       if (link_ptr->to->lln != ARTMAP_CMPb_LAY) {
  4917.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4918.       } /*if*/
  4919.  
  4920.       count_cmp++;
  4921.  
  4922.    } /*FOR_ALL_LINKS*/
  4923.  
  4924.    if (count_cmp != ArtMap_NoOfInpUnits_b) {
  4925.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4926.    } /*if*/
  4927.  
  4928.  
  4929.    /* topo_ptr points to reset general unit which is linked to
  4930.       the reset I unit and the reset C unit
  4931.    */
  4932.  
  4933.    unit_ptr = *(*topo_ptr)++;
  4934.  
  4935.    if (UNIT_HAS_SITES (unit_ptr)) {
  4936.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4937.    } /*if*/
  4938.  
  4939.    count_ri = 0;
  4940.    count_rc = 0;
  4941.  
  4942.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4943.  
  4944.       if (link_ptr->to->lln != ARTMAP_SPECb_LAY) {
  4945.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4946.       } /*if*/
  4947.  
  4948.       if (link_ptr->to->lun == ARTMAP_RIb_UNIT) {
  4949.          count_ri++;
  4950.          continue;
  4951.       } /*if*/
  4952.  
  4953.       if (link_ptr->to->lun == ARTMAP_RCb_UNIT) {
  4954.          count_rc++;
  4955.          continue;
  4956.       } /*if*/
  4957.  
  4958.       TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4959.  
  4960.    } /*FOR_ALL_LINKS*/
  4961.  
  4962.  
  4963.    if ((count_ri != 1) || (count_rc != 1)) {
  4964.       TOPO_MSG_LINK_MISSING (unit_ptr);
  4965.    } /*if*/
  4966.  
  4967.  
  4968.  
  4969.  
  4970.    /* topo_ptr points to RHOb unit which has an incoming links
  4971.       from itself
  4972.    */
  4973.  
  4974.    unit_ptr = *(*topo_ptr)++;
  4975.  
  4976.    if (UNIT_HAS_SITES (unit_ptr)) {
  4977.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  4978.    } /*if*/
  4979.  
  4980.    count_rho = 0;
  4981.  
  4982.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  4983.  
  4984.       switch (link_ptr->to->lln) {
  4985.       case ARTMAP_SPECb_LAY:
  4986.          if (link_ptr->to->lun == ARTMAP_RHOb_UNIT) {
  4987.             count_rho++;
  4988.          } else {
  4989.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4990.          }  /*if*/
  4991.          break;
  4992.       default:
  4993.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  4994.       } /*switch*/
  4995.  
  4996.    } /*FOR_ALL_LINKS*/
  4997.  
  4998.    if (count_rho != 1) {
  4999.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5000.    } /*if*/
  5001.  
  5002.  
  5003.  
  5004.  
  5005.    /* topo_ptr points to g2b unit which has incoming links
  5006.       from all inpb units
  5007.    */
  5008.  
  5009.    unit_ptr = *(*topo_ptr)++;
  5010.  
  5011.    if (UNIT_HAS_SITES (unit_ptr)) {
  5012.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5013.    } /*if*/
  5014.  
  5015.    count_inp = 0;
  5016.  
  5017.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5018.  
  5019.      if (link_ptr->to->lln == ARTMAP_INPb_LAY) {
  5020.         count_inp++;
  5021.      } else {
  5022.         TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5023.      } /*if*/
  5024.  
  5025.    } /*FOR_ALL_LINKS*/
  5026.  
  5027.    if (count_inp != ArtMap_NoOfInpUnits_b) {
  5028.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5029.    } /*if*/
  5030.  
  5031.  
  5032.    (*topo_ptr)++;  /* increment topo_ptr to next used position in array */
  5033.  
  5034.    return (ret_code);
  5035.  
  5036. } /* kram_LinksToSpecUnits_b () */
  5037. /*___________________________________________________________________________*/
  5038.  
  5039.  
  5040.  
  5041. /*********** functions to check links of map field of ARTMAP net
  5042. ***********/
  5043.  
  5044.  
  5045. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  5046. static krui_err   kram_LinksToMapUnits (TopoPtrArray *topo_ptr)
  5047. {
  5048.  
  5049.    krui_err                  ret_code    = KRERR_NO_ERROR;
  5050.  
  5051.    register struct Unit      *unit_ptr;
  5052.    register struct Link      *link_ptr;
  5053.  
  5054.    int                       count_dela,
  5055.                              count_delb,
  5056.                              count_G;
  5057.  
  5058.  
  5059.    /* - each map unit is linked to all dela units
  5060.       - each map unit is linked to its corresponding delb unit
  5061.       - each map unit is linked to the G unit
  5062.    */
  5063.  
  5064.    krart_deleteTouchFlags();
  5065.  
  5066.  
  5067.    while ((unit_ptr = *(*topo_ptr)++) != NULL) {
  5068.  
  5069.       if (UNIT_HAS_SITES (unit_ptr)) {
  5070.          TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5071.       } /*if*/
  5072.  
  5073.       count_dela = 0;
  5074.       count_delb = 0;
  5075.       count_G    = 0;
  5076.  
  5077.       FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5078.  
  5079.          switch (link_ptr->to->lln) {
  5080.          case ARTMAP_DELa_LAY:
  5081.             if (link_ptr->to->lun == ARTMAP_DELa_REC_UNIT) {
  5082.                count_dela++;
  5083.             } else {
  5084.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5085.             } /*if*/
  5086.             break;
  5087.          case ARTMAP_DELb_LAY:
  5088.             if ((link_ptr->to->lun == ARTMAP_DELb_REC_UNIT) &&
  5089.                 (!UNIT_REFRESHED (link_ptr->to))
  5090.                )
  5091.             {
  5092.                count_delb++;
  5093.                link_ptr->to->flags |= UFLAG_REFRESH;
  5094.             } else {
  5095.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5096.             } /*if*/
  5097.             break;
  5098.          case ARTMAP_SPEC_LAY:
  5099.             if (link_ptr->to->lun == ARTMAP_G_UNIT) {
  5100.                count_G++;
  5101.             } else {
  5102.                TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5103.             } /*if*/
  5104.             break;
  5105.          default:
  5106.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5107.          } /*switch*/
  5108.  
  5109.       } /*FOR_ALL_LINKS*/
  5110.  
  5111.       if ((count_dela != ArtMap_NoOfRecUnits_a) ||
  5112.           (count_delb != 1) || (count_G != 1)
  5113.          )
  5114.       {
  5115.          TOPO_MSG_LINK_MISSING (unit_ptr);
  5116.       } /*if*/
  5117.  
  5118.    } /*while*/
  5119.  
  5120.    return (ret_code);
  5121.  
  5122. } /* kram_LinksToMapUnits () */
  5123. /*___________________________________________________________________________*/
  5124.  
  5125.  
  5126.  
  5127. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  5128. static krui_err   kram_LinksToSpecUnits (TopoPtrArray *topo_ptr)
  5129. {
  5130.     krui_err                  ret_code  = KRERR_NO_ERROR;
  5131.  
  5132.     register struct Unit      *unit_ptr;
  5133.     register struct Site      *site_ptr;
  5134.     struct Site               *site_ptr1,
  5135.                               *site_ptr2;
  5136.     register struct Link      *link_ptr;
  5137.  
  5138.     TopoPtrArray              topo_d1_ptr,
  5139.                               topo_cl_ptr,
  5140.                               topo_nc_ptr,
  5141.                               topo_G_ptr,
  5142.                               topo_rb_ptr,
  5143.                               topo_rm_ptr,
  5144.                               topo_rg_ptr,
  5145.                               topo_rho_ptr,
  5146.                               topo_qu_ptr,
  5147.                               topo_drho_ptr;
  5148.  
  5149.     int                       count_delb,
  5150.                               count_d1,
  5151.                               count_cla,
  5152.                               count_clb,
  5153.                               count_nca,
  5154.                               count_ncb,
  5155.                               count_reca,
  5156.                               count_recb,
  5157.                               count_map,
  5158.                               count_rb,
  5159.                               count_rho,
  5160.                               count_rm,
  5161.                               count_inpa,
  5162.                               count_cmpa,
  5163.                               count_qu,
  5164.                               count_rhoa,
  5165.                               count_drho,
  5166.                               count_rg,
  5167.                               count_rga;
  5168.  
  5169.     /* let's set the special topo pointers
  5170.     */
  5171.     topo_d1_ptr      = *topo_ptr;
  5172.     topo_cl_ptr      = topo_d1_ptr + 1;
  5173.     topo_nc_ptr      = topo_cl_ptr + 1;
  5174.     topo_G_ptr       = topo_nc_ptr + 1;
  5175.     topo_rb_ptr      = topo_G_ptr + 1;
  5176.     topo_rm_ptr      = topo_rb_ptr + 1;
  5177.     topo_rg_ptr      = topo_rm_ptr + 1;
  5178.     topo_rho_ptr     = topo_rg_ptr + 1;
  5179.     topo_qu_ptr      = topo_rho_ptr + 1;
  5180.     topo_drho_ptr    = topo_qu_ptr + 1;
  5181.  
  5182.  
  5183.     /* first we check the links to the d1 unit :
  5184.        it has inputs from all delb units.
  5185.     */
  5186.     count_delb = 0;
  5187.     unit_ptr   = *topo_d1_ptr;
  5188.  
  5189.     if (UNIT_HAS_SITES (unit_ptr)) {
  5190.        TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5191.     } /*if*/
  5192.  
  5193.     FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5194.  
  5195.        if ((link_ptr->to->lln == ARTMAP_DELb_LAY) &&
  5196.            (link_ptr->to->lun == ARTMAP_DELb_REC_UNIT)
  5197.           )
  5198.        {
  5199.           count_delb++;
  5200.        } else {
  5201.           TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5202.        } /*if*/
  5203.  
  5204.     } /*FOR_ALL_LINKS*/
  5205.  
  5206.     if (count_delb != ArtMap_NoOfRecUnits_b) {
  5207.        TOPO_MSG_LINK_MISSING (unit_ptr);
  5208.     } /*if*/
  5209.  
  5210.  
  5211.     /* next we check the links to the cl unit
  5212.        it has inputs from the cla, the clb unit and the rg unit
  5213.     */
  5214.  
  5215.     count_cla   = 0;
  5216.     count_clb   = 0;
  5217.     count_rg    = 0;
  5218.     unit_ptr    = *topo_cl_ptr;
  5219.  
  5220.     if (UNIT_HAS_SITES (unit_ptr)) {
  5221.        TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5222.     } /*if*/
  5223.  
  5224.     FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5225.  
  5226.        switch (link_ptr->to->lln) {
  5227.        case ARTMAP_SPECa_LAY:
  5228.           if (link_ptr->to->lun == ARTMAP_CLa_UNIT) {
  5229.              count_cla++;
  5230.           } else {
  5231.              TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5232.           } /*if*/
  5233.           break;
  5234.        case ARTMAP_SPECb_LAY:
  5235.           if (link_ptr->to->lun == ARTMAP_CLb_UNIT) {
  5236.              count_clb++;
  5237.           } else {
  5238.              TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5239.           } /*if*/
  5240.           break;
  5241.        case ARTMAP_SPEC_LAY:
  5242.           if (link_ptr->to->lun == ARTMAP_RG_UNIT) {
  5243.              count_rg++;
  5244.           } else {
  5245.              TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5246.           } /*if*/
  5247.           break;
  5248.        default:
  5249.           TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5250.        } /*switch*/
  5251.  
  5252.     } /*FOR_ALL_LINKS*/
  5253.  
  5254.     if ((count_cla != 1) || (count_clb != 1) || (count_rg != 1)) {
  5255.        TOPO_MSG_LINK_MISSING (unit_ptr);
  5256.     } /*if*/
  5257.  
  5258.  
  5259.     /* next we check the links of the nc unit:
  5260.        it has inputs from the nca and the ncb unit
  5261.     */
  5262.  
  5263.     count_nca = 0;
  5264.     count_ncb = 0;
  5265.     unit_ptr  = *topo_nc_ptr;
  5266.  
  5267.     if (UNIT_HAS_SITES (unit_ptr)) {
  5268.        TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5269.     } /*if*/
  5270.  
  5271.     FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5272.  
  5273.        switch (link_ptr->to->lln) {
  5274.        case ARTMAP_SPECa_LAY:
  5275.           if (link_ptr->to->lun == ARTMAP_NCa_UNIT) {
  5276.              count_nca++;
  5277.           } else {
  5278.              TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5279.           } /*if*/
  5280.           break;
  5281.        case ARTMAP_SPECb_LAY:
  5282.           if (link_ptr->to->lun == ARTMAP_NCb_UNIT) {
  5283.              count_ncb++;
  5284.           } else {
  5285.              TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5286.           } /*if*/
  5287.           break;
  5288.        default:
  5289.           TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5290.        } /*switch*/
  5291.  
  5292.     } /*FOR_ALL_LINKS*/
  5293.  
  5294.     if ((count_nca != 1) || (count_ncb != 1)) {
  5295.        TOPO_MSG_LINK_MISSING (unit_ptr);
  5296.     } /*if*/
  5297.  
  5298.  
  5299.     /* next we check the links to the G unit
  5300.        it has inputs from all reca to one of its sites and from the recb
  5301.        units to the other site.
  5302.     */
  5303.  
  5304.     count_reca   = 0;
  5305.     count_recb   = 0;
  5306.     unit_ptr     = *topo_G_ptr;
  5307.     site_ptr1 = NULL;
  5308.     site_ptr2 = NULL;
  5309.  
  5310.     if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  5311.        TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  5312.     } /*if*/
  5313.  
  5314.  
  5315.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  5316.  
  5317.       switch (link_ptr->to->lln) {
  5318.  
  5319.       case ARTMAP_RECb_LAY :
  5320.  
  5321.          count_recb++;
  5322.  
  5323.          if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  5324.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5325.          } /*if*/
  5326.  
  5327.          site_ptr2 = site_ptr;
  5328.  
  5329.          if (site_ptr1 == site_ptr2) {
  5330.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5331.          } /*if*/
  5332.  
  5333.          break;
  5334.  
  5335.       case ARTMAP_RECa_LAY :
  5336.  
  5337.          count_reca++;
  5338.  
  5339.          if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  5340.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5341.          } /*if*/
  5342.  
  5343.          site_ptr1 = site_ptr;
  5344.  
  5345.          if (site_ptr1 == site_ptr2) {
  5346.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5347.          } /*if*/
  5348.  
  5349.          break;
  5350.  
  5351.       default :
  5352.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5353.  
  5354.       } /*switch*/
  5355.  
  5356.    } /*FOR_ALL_SITES_AND_LINKS*/
  5357.  
  5358.    if ((count_reca != ArtMap_NoOfRecUnits_a) ||
  5359.        (count_recb != ArtMap_NoOfRecUnits_b)
  5360.       )
  5361.    {
  5362.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5363.    } /*if*/
  5364.  
  5365.  
  5366.  
  5367.    /* next we check the links of the rb unit
  5368.       which  has one link from the d1 unit to one of its sites and
  5369.       one link from the rho unit to the other site.
  5370.    */
  5371.  
  5372.  
  5373.     count_d1     = 0;
  5374.     count_rho    = 0;
  5375.     unit_ptr     = *topo_rb_ptr;
  5376.     site_ptr1 = NULL;
  5377.     site_ptr2 = NULL;
  5378.  
  5379.     if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  5380.        TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  5381.     } /*if*/
  5382.  
  5383.  
  5384.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  5385.  
  5386.       if (link_ptr->to->lln == ARTMAP_SPEC_LAY) {
  5387.  
  5388.          switch (link_ptr->to->lun) {
  5389.          case ARTMAP_D1_UNIT:
  5390.             count_d1++;
  5391.  
  5392.             if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  5393.                TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5394.             } /*if*/
  5395.  
  5396.             site_ptr2 = site_ptr;
  5397.  
  5398.             if (site_ptr1 == site_ptr2) {
  5399.                TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5400.             } /*if*/
  5401.  
  5402.             break;
  5403.  
  5404.          case ARTMAP_RHO_UNIT:
  5405.             count_rho++;
  5406.  
  5407.             if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  5408.                TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5409.             } /*if*/
  5410.  
  5411.             site_ptr1 = site_ptr;
  5412.  
  5413.             if (site_ptr1 == site_ptr2) {
  5414.                TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5415.             } /*if*/
  5416.  
  5417.             break;
  5418.  
  5419.          default :
  5420.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5421.  
  5422.          } /*switch*/
  5423.  
  5424.       } else {
  5425.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5426.       } /*if*/
  5427.  
  5428.    } /*FOR_ALL_SITES_AND_LINKS*/
  5429.  
  5430.    if ((count_d1 != 1) || (count_rho != 1)) {
  5431.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5432.    } /*if*/
  5433.  
  5434.  
  5435.    /* next we check the links to the rm unit
  5436.       it has inputs from all map units
  5437.    */
  5438.  
  5439.    count_map  = 0;
  5440.    unit_ptr   = *topo_rm_ptr;
  5441.  
  5442.    if (UNIT_HAS_SITES (unit_ptr)) {
  5443.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5444.    } /*if*/
  5445.  
  5446.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5447.  
  5448.       if (link_ptr->to->lln == ARTMAP_MAP_LAY) {
  5449.          count_map++;
  5450.       } else {
  5451.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5452.       } /*if*/
  5453.  
  5454.    } /*FOR_ALL_LINKS*/
  5455.  
  5456.    if (count_map != ArtMap_NoOfRecUnits_b) {
  5457.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5458.    } /*if*/
  5459.  
  5460.  
  5461.  
  5462.    /* next we check the links to the rg unit
  5463.       it has inputs from the rb and the rm unit
  5464.    */
  5465.  
  5466.    count_rb   = 0;
  5467.    count_rm   = 0;
  5468.    unit_ptr   = *topo_rg_ptr;
  5469.  
  5470.    if (UNIT_HAS_SITES (unit_ptr)) {
  5471.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5472.    } /*if*/
  5473.  
  5474.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5475.  
  5476.       switch (link_ptr->to->lln) {
  5477.  
  5478.       case ARTMAP_SPEC_LAY :
  5479.          switch (link_ptr->to->lun) {
  5480.          case ARTMAP_RB_UNIT:
  5481.             count_rb++;
  5482.             break;
  5483.          case ARTMAP_RM_UNIT:
  5484.             count_rm++;
  5485.             break;
  5486.          default:
  5487.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5488.          } /*switch*/
  5489.          break;
  5490.  
  5491.       default:
  5492.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5493.          break;
  5494.  
  5495.       } /*switch*/
  5496.  
  5497.    } /*FOR_ALL_LINKS*/
  5498.  
  5499.    if ((count_rb != 1) || (count_rm != 1)) {
  5500.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5501.    } /*if*/
  5502.  
  5503.  
  5504.    /* next we check the links to the rho unit
  5505.       it has inputs just from itself
  5506.    */
  5507.  
  5508.    count_rho = 0;
  5509.    unit_ptr  = *topo_rho_ptr;
  5510.  
  5511.    if (UNIT_HAS_SITES (unit_ptr)) {
  5512.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5513.    } /*if*/
  5514.  
  5515.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5516.  
  5517.       if (unit_ptr == link_ptr->to) {
  5518.          count_rho++;
  5519.       } else {
  5520.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5521.       } /*if*/
  5522.  
  5523.    } /*FOR_ALL_LINKS*/
  5524.  
  5525.    if (count_rho != 1) {
  5526.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5527.    } /*if*/
  5528.  
  5529.  
  5530.  
  5531.    /* next we check the links to the qu unit
  5532.       it has inputs from all inpa units to one of its sites and
  5533.       from all cmpa units to the other site.
  5534.    */
  5535.  
  5536.    count_inpa  = 0;
  5537.    count_cmpa  = 0;
  5538.    unit_ptr    = *topo_qu_ptr;
  5539.    site_ptr1 = NULL;
  5540.    site_ptr2 = NULL;
  5541.  
  5542.    if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  5543.       TOPO_MSG_UNEXPECTED_DIRECT_INPUTS (unit_ptr);
  5544.    } /*if*/
  5545.  
  5546.  
  5547.    FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  5548.  
  5549.       switch (link_ptr->to->lln) {
  5550.  
  5551.       case ARTMAP_INPa_LAY :
  5552.  
  5553.          count_inpa++;
  5554.  
  5555.          if ((site_ptr2 != NULL) && (site_ptr2 != site_ptr)) {
  5556.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5557.          } /*if*/
  5558.  
  5559.          site_ptr2 = site_ptr;
  5560.  
  5561.          if (site_ptr1 == site_ptr2) {
  5562.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5563.          } /*if*/
  5564.  
  5565.          break;
  5566.  
  5567.       case ARTMAP_CMPa_LAY :
  5568.  
  5569.          count_cmpa++;
  5570.  
  5571.          if ((site_ptr1 != NULL) && (site_ptr1 != site_ptr)) {
  5572.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5573.          } /*if*/
  5574.  
  5575.          site_ptr1 = site_ptr;
  5576.  
  5577.          if (site_ptr1 == site_ptr2) {
  5578.             TOPO_MSG_LINK_TO_WRONG_SITE (link_ptr->to, unit_ptr);
  5579.          } /*if*/
  5580.  
  5581.          break;
  5582.  
  5583.       default :
  5584.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5585.  
  5586.       } /*switch*/
  5587.  
  5588.    } /*FOR_ALL_SITES_AND_LINKS*/
  5589.  
  5590.    if ((count_inpa != ArtMap_NoOfInpUnits_a) ||
  5591.        (count_cmpa != ArtMap_NoOfInpUnits_a)
  5592.       )
  5593.    {
  5594.       TOPO_MSG_LINK_MISSING (unit_ptr);
  5595.    } /*if*/
  5596.  
  5597.  
  5598.    /* finally we check the links to the drho unit
  5599.       it has inputs from itself, from the rg unit, from the qu unit
  5600.       and from the rhoa unit
  5601.    */
  5602.  
  5603.    count_drho   = 0;
  5604.    count_rg     = 0;
  5605.    count_qu     = 0;
  5606.    count_rhoa   = 0;
  5607.    count_rga    = 0;
  5608.    count_clb    = 0;
  5609.    unit_ptr     = *topo_drho_ptr;
  5610.  
  5611.    if (UNIT_HAS_SITES (unit_ptr)) {
  5612.       TOPO_MSG_UNEXPECTED_SITES (unit_ptr);
  5613.    } /*if*/
  5614.  
  5615.    FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5616.  
  5617.       switch (link_ptr->to->lln) {
  5618.       case ARTMAP_SPEC_LAY:
  5619.  
  5620.          switch (link_ptr->to->lun) {
  5621.          case ARTMAP_DRHO_UNIT:
  5622.             count_drho++;
  5623.             break;
  5624.          case ARTMAP_RG_UNIT:
  5625.             count_rg++;
  5626.             break;
  5627.          case ARTMAP_QU_UNIT:
  5628.             count_qu++;
  5629.             break;
  5630.          default:
  5631.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5632.          } /*switch*/
  5633.  
  5634.          break;
  5635.  
  5636.       case ARTMAP_SPECa_LAY:
  5637.  
  5638.          switch (link_ptr->to->lun) {
  5639.          case ARTMAP_RHOa_UNIT:
  5640.             count_rhoa++;
  5641.             break;
  5642.          case ARTMAP_RGa_UNIT:
  5643.             count_rga++;
  5644.             break;
  5645.          default:
  5646.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5647.             break;
  5648.          } /*switch*/
  5649.  
  5650.          break;
  5651.  
  5652.       case ARTMAP_SPECb_LAY:
  5653.  
  5654.          switch (link_ptr->to->lun) {
  5655.          case ARTMAP_CLb_UNIT:
  5656.             count_clb++;
  5657.             break;
  5658.          default:
  5659.             TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5660.             break;
  5661.          } /*switch*/
  5662.  
  5663.          break;
  5664.  
  5665.       default:
  5666.          TOPO_MSG_UNEXPECTED_LINK (link_ptr->to, unit_ptr);
  5667.       } /*switch*/
  5668.  
  5669.    } /*FOR_ALL_LINKS*/
  5670.  
  5671.    if ((count_drho != 1) || (count_rg   != 1) ||
  5672.        (count_qu   != 1) || (count_rhoa != 1) ||
  5673.        (count_rga  != 1) || (count_clb  != 1)
  5674.       )
  5675.    {
  5676.        TOPO_MSG_LINK_MISSING (unit_ptr);
  5677.    } /*if*/
  5678.  
  5679.    return (ret_code);
  5680.  
  5681.  
  5682. } /* kram_LinksToSpecUnits () */
  5683. /*___________________________________________________________________________*/
  5684.  
  5685.  
  5686.  
  5687.  
  5688. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  5689. /* NOTE: Don't call this function unless net has been topologically sorted
  5690.          with type ARTMAP_TOPO_TYPE
  5691. */
  5692.  
  5693. static krui_err kram_init_fix_weights (void)
  5694. {
  5695.  
  5696.    int                    ret_code  = KRERR_NO_ERROR;
  5697.  
  5698.    register struct Unit   *unit_ptr;
  5699.    register struct Site   *site_ptr;
  5700.    register struct Link   *link_ptr;
  5701.  
  5702.  
  5703.  
  5704.  
  5705.    FOR_ALL_UNITS (unit_ptr) {
  5706.  
  5707.       if (UNIT_HAS_INPUTS (unit_ptr)) {
  5708.  
  5709.          if (UNIT_HAS_DIRECT_INPUTS (unit_ptr)) {
  5710.  
  5711.             FOR_ALL_LINKS (unit_ptr, link_ptr) {
  5712.  
  5713.                kram_set_fix_weight (link_ptr->to, unit_ptr, &(link_ptr->weight));
  5714.  
  5715.             } /*FOR_ALL_LINKS*/
  5716.  
  5717.          } else {
  5718.  
  5719.             FOR_ALL_SITES_AND_LINKS (unit_ptr, site_ptr, link_ptr) {
  5720.  
  5721.                kram_set_fix_weight (link_ptr->to, unit_ptr, &(link_ptr->weight));
  5722.  
  5723.             } /*FOR_ALL_SITES_AND_LINKS*/
  5724.  
  5725.          } /*if*/
  5726.  
  5727.       } /*if*/
  5728.  
  5729.    } /*FOR_ALL_UNITS*/
  5730.  
  5731.  
  5732.    return (ret_code);
  5733.  
  5734. } /* kram_init_fix_weights () */
  5735. /*___________________________________________________________________________*/
  5736.  
  5737.  
  5738.  
  5739. /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  5740. static void  kram_set_fix_weight (struct Unit *src_unit, struct Unit *trgt_unit, FlintType *weight)
  5741. {
  5742.    switch (src_unit->lln) {
  5743.  
  5744.    case ARTMAP_INPa_LAY:
  5745.  
  5746.       switch (trgt_unit->lln) {
  5747.       case ARTMAP_CMPa_LAY:
  5748.          *weight = ARTMAP_LINK_INPa_CMPa;
  5749.          break;
  5750.       case ARTMAP_SPECa_LAY:
  5751.          switch (trgt_unit->lun) {
  5752.          case ARTMAP_G1a_UNIT:
  5753.             *weight = ARTMAP_LINK_INPa_G1a;
  5754.             break;
  5755.          case ARTMAP_RIa_UNIT:
  5756.             *weight = ARTMAP_LINK_INPa_RIa;
  5757.             break;
  5758.          case ARTMAP_G2a_UNIT:
  5759.             *weight = ARTMAP_LINK_INPa_G2a;
  5760.             break;
  5761.          } /*switch*/
  5762.          break;
  5763.       case ARTMAP_SPEC_LAY:
  5764.          *weight = ARTMAP_LINK_INPa_QU;
  5765.          break;
  5766.       } /*switch*/
  5767.  
  5768.       break;
  5769.  
  5770.    case ARTMAP_CMPa_LAY:
  5771.  
  5772.       switch (trgt_unit->lln) {
  5773.       case ARTMAP_SPECa_LAY:
  5774.          *weight = ARTMAP_LINK_CMPa_RCa;
  5775.          break;
  5776.       case ARTMAP_SPEC_LAY:
  5777.          *weight = ARTMAP_LINK_CMPa_QU;
  5778.          break;
  5779.       } /*switch*/
  5780.  
  5781.       break;
  5782.  
  5783.    case ARTMAP_RECa_LAY:
  5784.  
  5785.       switch (trgt_unit->lln) {
  5786.       case ARTMAP_DELa_LAY:
  5787.          *weight = ARTMAP_LINK_RECa_DELa;
  5788.          break;
  5789.       case ARTMAP_SPECa_LAY:
  5790.          *weight = ARTMAP_LINK_RECa_G1a;
  5791.          break;
  5792.       case ARTMAP_SPEC_LAY:
  5793.          *weight = ARTMAP_LINK_RECa_G;
  5794.          break;
  5795.       } /*switch*/
  5796.  
  5797.       break;
  5798.  
  5799.    case ARTMAP_DELa_LAY:
  5800.  
  5801.       switch (trgt_unit->lln) {
  5802.       case ARTMAP_DELa_LAY:
  5803.          *weight = ARTMAP_LINK_DELa_DELa;
  5804.          break;
  5805.       case ARTMAP_RSTa_LAY:
  5806.          *weight = ARTMAP_LINK_DELa_RSTa;
  5807.          break;
  5808.       case ARTMAP_SPECa_LAY:
  5809.          *weight = ARTMAP_LINK_DELa_CLa;
  5810.          break;
  5811.       } /*switch*/
  5812.  
  5813.       break;
  5814.  
  5815.    case ARTMAP_RSTa_LAY:
  5816.  
  5817.       switch (trgt_unit->lln) {
  5818.       case ARTMAP_RECa_LAY:
  5819.          *weight = ARTMAP_LINK_RSTa_RECa;
  5820.          break;
  5821.       case ARTMAP_RSTa_LAY:
  5822.          *weight = ARTMAP_LINK_RSTa_RSTa;
  5823.          break;
  5824.       case ARTMAP_SPECa_LAY:
  5825.          *weight = ARTMAP_LINK_RSTa_NCa;
  5826.          break;
  5827.       } /*switch*/
  5828.  
  5829.       break;
  5830.  
  5831.    case ARTMAP_SPECa_LAY:
  5832.  
  5833.       switch (src_unit->lun) {
  5834.  
  5835.       case ARTMAP_CLa_UNIT:
  5836.  
  5837.          *weight = ARTMAP_LINK_CLa_CL;
  5838.          break;
  5839.  
  5840.       case ARTMAP_NCa_UNIT:
  5841.  
  5842.          *weight = ARTMAP_LINK_NCa_NC;
  5843.          break;
  5844.  
  5845.       case ARTMAP_G1a_UNIT:
  5846.  
  5847.          *weight = ARTMAP_LINK_G1a_CMPa;
  5848.          break;
  5849.  
  5850.       case ARTMAP_RIa_UNIT:
  5851.  
  5852.          *weight = ARTMAP_LINK_RIa_RGa;
  5853.          break;
  5854.  
  5855.       case ARTMAP_RCa_UNIT:
  5856.  
  5857.          *weight = ARTMAP_LINK_RCa_RGa;
  5858.          break;
  5859.  
  5860.       case ARTMAP_RGa_UNIT:
  5861.  
  5862.          switch (trgt_unit->lln) {
  5863.          case ARTMAP_RECa_LAY:
  5864.             *weight = ARTMAP_LINK_RGa_RECa;
  5865.             break;
  5866.          case ARTMAP_RSTa_LAY:
  5867.             *weight = ARTMAP_LINK_RGa_RSTa;
  5868.             break;
  5869.          case ARTMAP_SPECa_LAY:
  5870.             *weight = ARTMAP_LINK_RGa_CLa;
  5871.             break;
  5872.          case ARTMAP_SPEC_LAY:
  5873.             *weight = ARTMAP_LINK_RGa_DRHO;
  5874.          } /*switch*/
  5875.          break;
  5876.  
  5877.       case ARTMAP_RHOa_UNIT:
  5878.  
  5879.          switch (trgt_unit->lln) {
  5880.          case ARTMAP_SPECa_LAY:
  5881.             switch (trgt_unit->lun) {
  5882.             case ARTMAP_RIa_UNIT:
  5883.                *weight = ARTMAP_LINK_RHOa_RIa;
  5884.                break;
  5885.             case ARTMAP_RHOa_UNIT:
  5886.                *weight = ARTMAP_LINK_RHOa_RHOa;
  5887.                break;
  5888.             } /*switch*/
  5889.             break;
  5890.          case ARTMAP_SPEC_LAY:
  5891.             *weight = ARTMAP_LINK_RHOa_DRHO;
  5892.             break;
  5893.          } /*switch*/
  5894.  
  5895.          break;
  5896.  
  5897.       case ARTMAP_G2a_UNIT:
  5898.  
  5899.          switch (trgt_unit->lln) {
  5900.          case ARTMAP_RECa_LAY:
  5901.             *weight = ARTMAP_LINK_G2a_RECa;
  5902.             break;
  5903.          case ARTMAP_SPECa_LAY:
  5904.             *weight = ARTMAP_LINK_G2a_CLa;
  5905.             break;
  5906.          } /*switch*/
  5907.  
  5908.          break;
  5909.  
  5910.       } /*switch*/
  5911.  
  5912.       break;
  5913.  
  5914.    case ARTMAP_INPb_LAY:
  5915.  
  5916.       switch (trgt_unit->lln) {
  5917.       case ARTMAP_CMPb_LAY:
  5918.          *weight = ARTMAP_LINK_INPb_CMPb;
  5919.          break;
  5920.       case ARTMAP_SPECb_LAY:
  5921.          switch (trgt_unit->lun) {
  5922.          case ARTMAP_G1b_UNIT:
  5923.             *weight = ARTMAP_LINK_INPb_G1b;
  5924.             break;
  5925.          case ARTMAP_RIb_UNIT:
  5926.             *weight = ARTMAP_LINK_INPb_RIb;
  5927.             break;
  5928.          case ARTMAP_G2b_UNIT:
  5929.             *weight = ARTMAP_LINK_INPb_G2b;
  5930.             break;
  5931.          } /*switch*/
  5932.          break;
  5933.       } /*switch*/
  5934.  
  5935.       break;
  5936.  
  5937.    case ARTMAP_CMPb_LAY:
  5938.  
  5939.       switch (trgt_unit->lln) {
  5940.       case ARTMAP_SPECb_LAY:
  5941.          *weight = ARTMAP_LINK_CMPb_RCb;
  5942.          break;
  5943.       } /*switch*/
  5944.  
  5945.    case ARTMAP_RECb_LAY:
  5946.  
  5947.       switch (trgt_unit->lln) {
  5948.       case ARTMAP_DELb_LAY:
  5949.          *weight = ARTMAP_LINK_RECb_DELb;
  5950.          break;
  5951.       case ARTMAP_SPECb_LAY:
  5952.          *weight = ARTMAP_LINK_RECb_G1b;
  5953.          break;
  5954.       case ARTMAP_SPEC_LAY:
  5955.          *weight = ARTMAP_LINK_RECb_G;
  5956.          break;
  5957.       } /*switch*/
  5958.  
  5959.       break;
  5960.  
  5961.    case ARTMAP_DELb_LAY:
  5962.  
  5963.       switch (trgt_unit->lln) {
  5964.       case ARTMAP_DELb_LAY:
  5965.          *weight = ARTMAP_LINK_DELb_DELb;
  5966.          break;
  5967.       case ARTMAP_RSTb_LAY:
  5968.          *weight = ARTMAP_LINK_DELb_RSTb;
  5969.          break;
  5970.       case ARTMAP_SPECb_LAY:
  5971.          *weight = ARTMAP_LINK_DELb_CLb;
  5972.          break;
  5973.       case ARTMAP_MAP_LAY:
  5974.          *weight = ARTMAP_LINK_DELb_MAP;
  5975.          break;
  5976.       case ARTMAP_SPEC_LAY:
  5977.          *weight = ARTMAP_LINK_DELb_D1;
  5978.          break;
  5979.       } /*switch*/
  5980.  
  5981.       break;
  5982.  
  5983.    case ARTMAP_RSTb_LAY:
  5984.  
  5985.       switch (trgt_unit->lln) {
  5986.       case ARTMAP_RECb_LAY:
  5987.          *weight = ARTMAP_LINK_RSTb_RECb;
  5988.          break;
  5989.       case ARTMAP_RSTb_LAY:
  5990.          *weight = ARTMAP_LINK_RSTb_RSTb;
  5991.          break;
  5992.       case ARTMAP_SPECb_LAY:
  5993.          *weight = ARTMAP_LINK_RSTb_NCb;
  5994.          break;
  5995.       } /*switch*/
  5996.  
  5997.       break;
  5998.  
  5999.    case ARTMAP_SPECb_LAY:
  6000.  
  6001.       switch (src_unit->lun) {
  6002.  
  6003.       case ARTMAP_CLb_UNIT:
  6004.  
  6005.          switch (trgt_unit->lun) {
  6006.          case ARTMAP_CL_UNIT:
  6007.             *weight = ARTMAP_LINK_CLb_CL;
  6008.             break;
  6009.          case ARTMAP_DRHO_UNIT:
  6010.             *weight = ARTMAP_LINK_CLb_DRHO;
  6011.             break;
  6012.          } /*switch*/
  6013.  
  6014.          break;
  6015.  
  6016.       case ARTMAP_NCa_UNIT:
  6017.  
  6018.          *weight = ARTMAP_LINK_NCb_NC;
  6019.          break;
  6020.  
  6021.       case ARTMAP_G1b_UNIT:
  6022.  
  6023.          *weight = ARTMAP_LINK_G1b_CMPb;
  6024.          break;
  6025.  
  6026.       case ARTMAP_RIb_UNIT:
  6027.  
  6028.          *weight = ARTMAP_LINK_RIb_RGb;
  6029.          break;
  6030.  
  6031.       case ARTMAP_RCb_UNIT:
  6032.  
  6033.          *weight = ARTMAP_LINK_RCb_RGb;
  6034.          break;
  6035.  
  6036.       case ARTMAP_RGb_UNIT:
  6037.  
  6038.          switch (trgt_unit->lln) {
  6039.          case ARTMAP_RECb_LAY:
  6040.             *weight = ARTMAP_LINK_RGb_RECb;
  6041.             break;
  6042.          case ARTMAP_RSTb_LAY:
  6043.             *weight = ARTMAP_LINK_RGb_RSTb;
  6044.             break;
  6045.          case ARTMAP_SPECb_LAY:
  6046.             *weight = ARTMAP_LINK_RGb_CLb;
  6047.             break;
  6048.          } /*switch*/
  6049.          break;
  6050.  
  6051.       case ARTMAP_RHOb_UNIT:
  6052.  
  6053.          switch (trgt_unit->lun) {
  6054.          case ARTMAP_RIb_UNIT:
  6055.             *weight = ARTMAP_LINK_RHOa_RIa;
  6056.             break;
  6057.          case ARTMAP_RHOb_UNIT:
  6058.             *weight = ARTMAP_LINK_RHOa_RHOa;
  6059.             break;
  6060.          } /*switch*/
  6061.  
  6062.          break;
  6063.  
  6064.       case ARTMAP_G2b_UNIT:
  6065.  
  6066.          switch (trgt_unit->lln) {
  6067.          case ARTMAP_RECb_LAY:
  6068.             *weight = ARTMAP_LINK_G2b_RECb;
  6069.             break;
  6070.          case ARTMAP_SPECb_LAY:
  6071.             *weight = ARTMAP_LINK_G2b_CLb;
  6072.             break;
  6073.          } /*switch*/
  6074.  
  6075.          break;
  6076.  
  6077.       } /*switch*/
  6078.  
  6079.       break;
  6080.  
  6081.  
  6082.    case ARTMAP_MAP_LAY:
  6083.  
  6084.       switch (trgt_unit->lln) {
  6085.       case ARTMAP_SPEC_LAY:
  6086.          *weight = ARTMAP_LINK_MAP_RM;
  6087.          break;
  6088.       case ARTMAP_DELb_LAY:
  6089.          *weight = ARTMAP_LINK_MAP_DELb;
  6090.          break;
  6091.       } /*switch*/
  6092.  
  6093.       break;
  6094.  
  6095.    case ARTMAP_SPEC_LAY:
  6096.  
  6097.       switch (src_unit->lun) {
  6098.  
  6099.       case ARTMAP_D1_UNIT:
  6100.  
  6101.          *weight = ARTMAP_LINK_D1_RB;
  6102.          break;
  6103.  
  6104.       case ARTMAP_G_UNIT:
  6105.  
  6106.          *weight = ARTMAP_LINK_G_MAP;
  6107.          break;
  6108.  
  6109.       case ARTMAP_RB_UNIT:
  6110.  
  6111.          *weight = ARTMAP_LINK_RB_RG;
  6112.          break;
  6113.  
  6114.       case ARTMAP_RM_UNIT:
  6115.  
  6116.          *weight = ARTMAP_LINK_RM_RG;
  6117.          break;
  6118.  
  6119.       case ARTMAP_RG_UNIT:
  6120.  
  6121.          switch (trgt_unit->lun) {
  6122.          case ARTMAP_CL_UNIT:
  6123.             *weight = ARTMAP_LINK_RG_CL;
  6124.             break;
  6125.          case ARTMAP_DRHO_UNIT:
  6126.             *weight = ARTMAP_LINK_RG_DRHO;
  6127.             break;
  6128.          } /*switch*/
  6129.  
  6130.          break;
  6131.  
  6132.       case ARTMAP_RHO_UNIT:
  6133.  
  6134.          switch (trgt_unit->lun) {
  6135.          case ARTMAP_RB_UNIT:
  6136.             *weight = ARTMAP_LINK_RHO_RB;
  6137.             break;
  6138.          case ARTMAP_RHO_UNIT:
  6139.             *weight = ARTMAP_LINK_RHO_RHO;
  6140.             break;
  6141.          } /*switch*/
  6142.  
  6143.          break;
  6144.  
  6145.       case ARTMAP_QU_UNIT:
  6146.  
  6147.          *weight = ARTMAP_LINK_QU_DRHO;
  6148.          break;
  6149.  
  6150.       case ARTMAP_DRHO_UNIT:
  6151.  
  6152.          switch (trgt_unit->lln) {
  6153.          case ARTMAP_SPECa_LAY:
  6154.             *weight = ARTMAP_LINK_DRHO_RHOa;
  6155.             break;
  6156.          case ARTMAP_SPEC_LAY:
  6157.             *weight = ARTMAP_LINK_DRHO_DRHO;
  6158.             break;
  6159.          } /* switch */
  6160.  
  6161.          break;
  6162.  
  6163.       } /*switch*/
  6164.  
  6165.       break;
  6166.  
  6167.    } /*switch*/
  6168.  
  6169. } /* kram_set_fix_weight () */
  6170. /*___________________________________________________________________________*/
  6171.